Skip to content

Commit

Permalink
Merge pull request #51 from alekodu/dev
Browse files Browse the repository at this point in the history
Stress-ng customisation of timeout
  • Loading branch information
salehsedghpour authored May 6, 2022
2 parents 3bb384e + 2e4900d commit dcf87f1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion generator/src/pkg/service/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const (
EpExecModeDefault = "sequential"
EpNwResponseSizeDefault = 512

EpExecTimeDefault = "1s"
EpExecTimeDefault = "0.1s"
EpMethodDefault = "all"
EpWorkersDefault = 1
EpLoadDefault = "5%"
Expand Down
25 changes: 24 additions & 1 deletion model/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,36 @@ FROM python:3.8.0-slim

RUN mkdir -p /usr/src/app
RUN apt update
RUN apt upgrade -y
RUN apt install -y jq \
wget \
stress-ng \
2to3

RUN apt install -y libbsd-dev \
libcap-dev \
libipsec-mb-dev \
libjudy-dev \
libkeyutils-dev \
libsctp-dev \
libatomic1 \
zlib1g-dev \
libkmod-dev \
libxxhash-dev \
git \
build-essential

WORKDIR /usr/src/app

RUN git clone https://github.com/alekodu/stress-ng.git &&\
cd stress-ng/ &&\
git checkout cloudsim &&\
make clean &&\
make &&\
mv stress-ng my-stress-ng &&\
cp my-stress-ng /usr/src/app &&\
cd .. &&\
rm -R stress-ng/

ADD ./requirements.txt /usr/src/app/requirements.txt

RUN pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions model/restful/utils/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ def run_task(service_name, service_endpoint):

def execute_cpu_bounded_task(conf):
if len(conf["cpu_affinity"]) > 0:
res = subprocess.run(['stress-ng --class cpu --cpu %s --cpu-method %s --taskset %s --cpu-load %s --timeout %s --metrics-brief' % (conf["workers"], conf["method"], ",".join(str(cpu_id) for cpu_id in conf["cpu_affinity"]), conf["cpu_load"], conf["execution_time"])], capture_output=True, shell=True)
res = subprocess.run(['/usr/src/app/my-stress-ng --class cpu --cpu %s --cpu-method %s --taskset %s --cpu-load %s --timeout %s --metrics-brief' % (conf["workers"], conf["method"], ",".join(str(cpu_id) for cpu_id in conf["cpu_affinity"]), conf["cpu_load"], conf["execution_time"])], capture_output=True, shell=True)
else:
res = subprocess.run(['stress-ng --class cpu --cpu %s --cpu-method %s --cpu-load %s --timeout %s --metrics-brief' % (conf["workers"], conf["method"], conf["cpu_load"], conf["execution_time"])], capture_output=True, shell=True)
res = subprocess.run(['/usr/src/app/my-stress-ng --class cpu --cpu %s --cpu-method %s --cpu-load %s --timeout %s --metrics-brief' % (conf["workers"], conf["method"], conf["cpu_load"], conf["execution_time"])], capture_output=True, shell=True)

return res.stderr.decode("utf-8"), "cpu"


def execute_memory_bounded_task(conf):
res = subprocess.run(['stress-ng --class memory --vm %s --vm-method %s --vm-bytes %s --timeout %s --metrics-brief' % (conf["workers"], conf["method"], conf["bytes_load"], conf["execution_time"])], capture_output=True, shell=True)
res = subprocess.run(['/usr/src/app/my-stress-ng --class memory --vm %s --vm-method %s --vm-bytes %s --timeout %s --metrics-brief' % (conf["workers"], conf["method"], conf["bytes_load"], conf["execution_time"])], capture_output=True, shell=True)

return res.stderr.decode("utf-8"), "memory"

Expand Down

0 comments on commit dcf87f1

Please sign in to comment.