-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add very basic non-docker testing for hashicorp/nomad#24339
(cleanup after yourself)
- Loading branch information
Showing
6 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nomad* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |