summaryrefslogtreecommitdiffstats
path: root/Bombs/mem/sx.sh
blob: bc99504937506e9ec00d173bb2611a690762572b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
export TERM=xterm
pid=0

function display_container_header {
    echo "+====================================================="
    echo "| Container   : $HOSTNAME"
    echo "| OS          : $(</etc/redhat-release)"
    echo "| kubernetes  : $KUBERNETES_SERVICE_HOST"
    echo "| user        : $(whoami)"
    echo "+====================================================="
}

function start_service {
    if [ ! -v TEST_DURATION ]; then
        TEST_DURATION=10;
        export TEST_DURATION;
    fi
    if echo $TEST_DURATION | egrep -q '^[0-9]+$'; then
        echo "" > /dev/null &
    else
        TEST_DURATION=10;
    fi
    echo "+====================================================="
    echo "| Container $HOSTNAME is now bombing MEM for $TEST_DURATION sec"
    echo "+====================================================="
    /bin/bomb > /dev/null &
    TASK_PID=$!
    sleep $TEST_DURATION
    kill $TASK_PID
    exit 0
}

display_container_header
start_service