diff options
Diffstat (limited to 'Bombs/mem')
-rw-r--r-- | Bombs/mem/Dockerfile | 8 | ||||
-rw-r--r-- | Bombs/mem/README.md | 69 | ||||
-rw-r--r-- | Bombs/mem/bomb.sh | 7 | ||||
-rw-r--r-- | Bombs/mem/docker-compose.yml | 10 | ||||
-rw-r--r-- | Bombs/mem/sx.sh | 65 |
5 files changed, 159 insertions, 0 deletions
diff --git a/Bombs/mem/Dockerfile b/Bombs/mem/Dockerfile new file mode 100644 index 0000000..2a37769 --- /dev/null +++ b/Bombs/mem/Dockerfile @@ -0,0 +1,8 @@ +FROM centos/s2i-core-centos7:latest +MAINTAINER Christophe LARUE <dev@startx.fr> + +COPY sx.sh /bin/sx +COPY bomb.sh /bin/bomb +RUN chmod 775 /bin/sx /bin/bomb + +CMD [ "/bin/sx" ] diff --git a/Bombs/mem/README.md b/Bombs/mem/README.md new file mode 100644 index 0000000..7597326 --- /dev/null +++ b/Bombs/mem/README.md @@ -0,0 +1,69 @@ +# Docker Bomb Images : mem + +Simple container used to bomb mem usage for crash testing. !!! WARNING, starting this container will start flooding your mem by default for 10sec. + +You can find information on this image and how to use it by visiting the [Dockerhub registry](https://github.com/startxfr/docker-images) + +| [![Build Status](https://travis-ci.org/startxfr/docker-images.svg?branch=openshift)](https://travis-ci.org/startxfr/docker-images) | [Dockerhub Registry](https://hub.docker.com/r/startx/openshift-bomb-mem) | [Sources](https://github.com/startxfr/docker-images/Bombs/) | [STARTX Profile](https://github.com/startxfr) | +|-------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|----------------------------------------------------------------------|-----------------------------------------------| + +## Running from dockerhub registry + +* with `docker` you can run `docker run -it --name="centos" startx/openshift-bomb-mem` from any docker host +* with `docker-compose` you can create a docker-compose.yml file with the following content +``` +fedora: + image: startx/openshift-bomb-mem:latest + container_name: "os-ocp-bomb-mem" + environment: + CONTAINER_TYPE: "bomb" + CONTAINER_SERVICE: "mem" + CONTAINER_INSTANCE: "os-ocp-bomb-mem" +``` + +## Using this image in your own container + +You can use this Dockerfile template to start a new personalized container based on this container + ``` +FROM startx/openshift-bomb-mem:latest +#... your container specifications +CMD ["/bin/sx"] +``` + +## Environment variable + +| Variable | Type | Mandatory | Description | +|---------------------------|----------|-----------|--------------------------------------------------------------------------| +| CONTAINER_INSTANCE | `string` | `yes` | Container name. Should be uning to get fine grained log and application reporting +| CONTAINER_TYPE | `string` | `no` | Container family (os, service, application. could be enhanced +| CONTAINER_SERVICE | `string` | `no` | Define the type of service or application provided +| HOSTNAME | `auto` | `auto` | Container unique id automatically assigned by docker daemon at startup +| TEST_DURATION | `seconds`| `auto` | Running test duration (defautl = 10sec) + + +## For advanced users + +You you want to use this container and code to build and create locally this container. You can follow theses instructions to setup and working environment. + +This section will help you if you want to : +* Get latest version of this container Bombs +* Enhance container content by adding instruction in Dockefile before build step + +You must have a working environment with the source code of this repository. Read and follow [how to setup your working environment](https://github.com/startxfr/docker-images#setup-your-working-environment-mandatory) to get a working directory. The following instructions assume you are at the top level of your working directory. + +### Build & run a container using `docker` + +1. Jump into the container directory with `cd Bombs/mem` +2. Build the container using `docker build -t bomb-mem .` +3. Run this container + 1. Interactively with `docker run -it bomb-mem`. If you add a last parameter (like `/bin/bash`) to will run this command instead of the default entrypoint. Usefull to interact with this container (ex: `/bin/bash`, `/bin/ps -a`, `/bin/df -h`,...) + 2. As a daemon with `docker run -d bomb-mem` + + +### Build & run a container using `docker-compose` + +1. Jump into the container directory with `cd Bombs/mem` +2. Run this container + 1. Interactively with `docker-compose up` Startup logs appears and escaping this command stop the container + 2. As a daemon with `docker-compose up -d`. Container startup logs can be read using `docker-compose logs` + diff --git a/Bombs/mem/bomb.sh b/Bombs/mem/bomb.sh new file mode 100644 index 0000000..a24d108 --- /dev/null +++ b/Bombs/mem/bomb.sh @@ -0,0 +1,7 @@ +#!/bin/bash +VARMEM=$(mount) +VARMEM="$VARMEM alejf iuoyzefdsljfhefgdsknchs,dmlqf,chlsegfcdkfhsjcgsqkfcgsqf" +while true +do + VARMEM="$VARMEM $VARMEM $VARMEM $VARMEM $VARMEM $VARMEM $VARMEM $VARMEM " +done
\ No newline at end of file diff --git a/Bombs/mem/docker-compose.yml b/Bombs/mem/docker-compose.yml new file mode 100644 index 0000000..0cc6823 --- /dev/null +++ b/Bombs/mem/docker-compose.yml @@ -0,0 +1,10 @@ +bomb-mem: + build: ./ + container_name: "os-ocp-bomb-mem" + mem_limit: 50m + memswap_limit: 300m + environment: + CONTAINER_TYPE: "bomb" + CONTAINER_SERVICE: "mem" + CONTAINER_INSTANCE: "os-ocp-bomb-mem" + TEST_DURATION: 15
\ No newline at end of file diff --git a/Bombs/mem/sx.sh b/Bombs/mem/sx.sh new file mode 100644 index 0000000..fd9115e --- /dev/null +++ b/Bombs/mem/sx.sh @@ -0,0 +1,65 @@ +#!/bin/bash +export TERM=xterm +pid=0 + +function check_environment { + if [ ! -v CONTAINER_TYPE ]; then + CONTAINER_TYPE="unknown" + export CONTAINER_TYPE + echo "! WARNING : environment var CONTAINER_TYPE is missing..." + echo "! WARNING : auto-assigned value : $CONTAINER_TYPE" + fi + if [ ! -v CONTAINER_SERVICE ]; then + CONTAINER_SERVICE=$CONTAINER_TYPE; + export CONTAINER_SERVICE; + echo "! WARNING : environment var CONTAINER_SERVICE is missing..." + echo "! WARNING : auto-assigned value : $CONTAINER_SERVICE" + fi + if [ ! -v CONTAINER_INSTANCE ]; then + CONTAINER_INSTANCE=$CONTAINER_TYPE "_" $CONTAINER_SERVICE; + export CONTAINER_INSTANCE; + echo "! WARNING : environment var CONTAINER_INSTANCE is missing..." + echo "! WARNING : auto-assigned value : $CONTAINER_INSTANCE" + fi +} + +function display_container_header { + echo "+=====================================================" + echo "| Container : $HOSTNAME" + echo "| OS : $(</etc/redhat-release)" + if [ -v CONTAINER_TYPE ]; then + echo "| Type : $CONTAINER_TYPE" + fi + if [ -v CONTAINER_SERVICE ]; then + echo "| Service : $CONTAINER_SERVICE" + fi + if [ -v CONTAINER_INSTANCE ]; then + echo "| Instance : $CONTAINER_INSTANCE" + fi + 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 +} + + +check_environment +display_container_header +start_service
\ No newline at end of file |