From a7a42f529a56af376434ba062e7e236917c57310 Mon Sep 17 00:00:00 2001 From: olaf michaelis Date: Mon, 11 Dec 2023 11:15:40 +0100 Subject: [PATCH] Update tests --- .gitignore | 2 ++ Taskfile.yml | 8 ++++---- testdata/Dockerfile | 6 +++--- testdata/drun.sh | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 7 deletions(-) create mode 100755 testdata/drun.sh diff --git a/.gitignore b/.gitignore index 61e2711..0cdf700 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ .imdone/ .task/ build/ +testdata/bin/ tmp/ + go.trace secret.toml diff --git a/Taskfile.yml b/Taskfile.yml index 9a35883..7c67ccf 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -55,12 +55,12 @@ tasks: desc: run docker to test memory issue inside dir: testdata cmds: - - cmd: cp "{{.CURDIR}}/build/linux_x86_64/logaxe" "{{.CURDIR}}/testdata/tmp" + - cmd: cp "{{.CURDIR}}/build/linux_x86_64/logaxe" "{{.CURDIR}}/testdata/bin/" + - cmd: cp "$(which fakedata)" "{{.CURDIR}}/testdata/bin/" - cmd: docker build --tag logaxe-test . - cmd: >- docker ps -a | grep logaxe-test | grep -Po "^[0-9a-f]+" | xargs -i docker rm {} - cmd: >- - docker run --kernel-memory="500m" --memory-swap="400m" - --memory="300m" --name logaxe-test logaxe-test - - cmd: docker logs -f logaxe-test + docker run --kernel-memory="64m" --memory-swap="128m" + --memory="128m" --name logaxe-test logaxe-test diff --git a/testdata/Dockerfile b/testdata/Dockerfile index e260cb7..a8237ad 100644 --- a/testdata/Dockerfile +++ b/testdata/Dockerfile @@ -1,4 +1,4 @@ FROM centos:latest -COPY ./tmp/logaxe / -RUN dd if=/dev/random of=/sample.log bs=1G count=1 -CMD ["/logaxe", "/"] +COPY ./bin/* /usr/bin/ +COPY ./drun.sh / +CMD ["/drun.sh"] diff --git a/testdata/drun.sh b/testdata/drun.sh new file mode 100755 index 0000000..76dc3ab --- /dev/null +++ b/testdata/drun.sh @@ -0,0 +1,16 @@ +#!/bin/sh +fol="/tmp/log" + +rcmd() { + cmd=${@} + echo -e "\033[0;93m${cmd}\033[0m" + eval ${cmd} +} + +rcmd mkdir -p "${fol}" + +cd ${fol} && { + rcmd dd if=/dev/random of=sample.log bs=2M count=1024 + rcmd logaxe "${fol}" + ls -lah +}