Skip to content

Commit

Permalink
add very basic non-docker testing for hashicorp/nomad#24339
Browse files Browse the repository at this point in the history
(cleanup after yourself)
  • Loading branch information
dmclf committed Nov 12, 2024
1 parent f822fe2 commit 1d1993a
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 0 deletions.
1 change: 1 addition & 0 deletions gh-24339/no-docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nomad*
4 changes: 4 additions & 0 deletions gh-24339/no-docker/.screenrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
screen -t consul 1 sudo consul agent -config-file=cfg/consul-server.hcl
screen -t server 2 sudo ./nomad agent -config=cfg/nomad-server.hcl -server
screen -t client 3 sudo ./nomad agent -config=cfg/nomad-client.hcl -client
screen -t stats 4 ./test
6 changes: 6 additions & 0 deletions gh-24339/no-docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# non-docker test method
- requires
- screen
- nomad
- consul
- start: `screen -c .screenrc`
25 changes: 25 additions & 0 deletions gh-24339/no-docker/cfg/consul-server.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
datacenter = "global"
primary_datacenter = "global"
data_dir = "/tmp/consul-data"
bind_addr = "127.0.0.1"
client_addr = "0.0.0.0"
server = true
bootstrap = true

ui_config {
enabled = true
}
peering {
enabled = true
}
connect {
enabled = true
}

ports {
http = 8500
}

disable_update_check = true
disable_remote_exec = true
enable_script_checks = true
23 changes: 23 additions & 0 deletions gh-24339/no-docker/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
VNOMAD="${1:-1.9.3}"
case `uname -m` in
aarch64) ARCH=arm64;;
x86_64) ARCH=amd64;;
esac

if test ! -f nomad_${VNOMAD}_linux_${ARCH}.zip
then
curl -L -o nomad_${VNOMAD}_linux_${ARCH}.zip https://releases.hashicorp.com/nomad/${VNOMAD}/nomad_${VNOMAD}_linux_${ARCH}.zip
fi
unzip -o nomad_${VNOMAD}_linux_${ARCH}.zip nomad
./nomad version

read -n1 -p "Proceed with test nomad ${VNOMAD} ${ARCH} ? (y = yes) " -r approval
echo
if [[ "$approval" =~ [Yy] ]]
then
echo OK
screen -c .screenrc
else
echo Abort Abort Abort Abort Abort
fi
62 changes: 62 additions & 0 deletions gh-24339/no-docker/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
echo "wait a bit before submitting job to allow nomad to settle"
sleep 60

cat << EOF > /tmp/test-job
# from https://github.com/hashicorp/nomad/issues/24339
job "example-job" {
group "cache" {
count = 20
ephemeral_disk {
size = 10
}

task "redis" {
driver = "docker"
config {
image = "redis:7"
auth_soft_fail = true
}

logs {
max_files = 3
max_file_size = 3
}

identity {
env = true
file = true
}

resources {
cpu = 100
memory = 64
}
}
}
}
EOF

nomad job run /tmp/test-job


localip="${1:-127.0.0.1}"
localport="${2:-4000}"

while true;
do

nomad_client_tasks_running=$(curl "http://${localip}:${localport}/v1/metrics?format=prometheus" 2>/dev/null|grep ^nomad_client_tasks_running|cut -f2 -d\} | awk '{print $1}')
nomad_client_allocs_memory_usage_count=$(curl "http://${localip}:${localport}/v1/metrics?format=prometheus" 2>/dev/null|grep -v ^# | grep alloc|grep nomad_client_allocs_memory_usage | wc -l )

if test -z "$nomad_client_tasks_running"; then nomad_client_tasks_running=-1;fi
if test -z "$nomad_client_allocs_memory_usage_count"; then nomad_client_allocs_memory_usage_count=-1;fi

if test $nomad_client_tasks_running -eq $nomad_client_allocs_memory_usage_count
then
echo "check $i :: ALL OK $nomad_client_tasks_running == $nomad_client_allocs_memory_usage_count"
else
echo "check $i :: MISMATCH $nomad_client_tasks_running != $nomad_client_allocs_memory_usage_count"
fi

sleep 5
done

0 comments on commit 1d1993a

Please sign in to comment.