Merge e2e and deploy-review Nomad job for CI

This way we don't have to manage two separate job files.
This commit is contained in:
sirkrypt0
2021-05-17 13:18:10 +02:00
committed by Tobias Kantusch
parent 24b7f1a2fa
commit 0d697bfd67
4 changed files with 18 additions and 58 deletions

View File

@ -114,8 +114,8 @@ test_e2e:
- export NOMAD_ADDR=http://localhost:4646
- nomad agent -dev -log-level=WARN &
- sleep 5
# Setup Nomad job and wait for it
- nomad run ci/e2e-test.nomad
- export NOMAD_NAMESPACE="default"
- ./ci/nomad-run-env-job.sh ci/demo-job.tpl.nomad ci/demo-job.nomad
- sleep 5
# Start Poseidon and wait for it
- ./poseidon &
@ -158,10 +158,7 @@ deploy_review:
before_script:
- export NOMAD_NAMESPACE="$NOMAD_SLUG"
- nomad namespace apply $NOMAD_NAMESPACE
- envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < ci/deploy-review.tpl.nomad > ci/deploy-review.nomad
- nomad validate ci/deploy-review.nomad
- nomad plan ci/deploy-review.nomad || [ $? == 1 ]
- nomad run ci/deploy-review.nomad
- ./ci/nomad-run-env-job.sh ci/demo-job.tpl.nomad ci/demo-job.nomad
only:
- branches
- tags

View File

@ -3,6 +3,7 @@
job "python" {
datacenters = ["dc1"]
type = "batch"
namespace = "${NOMAD_NAMESPACE}"
group "python-group" {
ephemeral_disk {

View File

@ -1,52 +0,0 @@
// This job is used by our deploy CI stage to create a seed job.
job "python" {
datacenters = ["dc1"]
type = "batch"
namespace = "${NOMAD_NAMESPACE}"
group "python" {
ephemeral_disk {
migrate = false
size = 10
sticky = false
}
count = 5
scaling {
enabled = true
max = 300
}
spread {
// see https://www.nomadproject.io/docs/job-specification/spread#even-spread-across-data-center
// This spreads the load evenly amongst our nodes
attribute = "${node.unique.name}"
weight = 100
}
task "python" {
driver = "docker"
kill_timeout = "0s"
kill_signal = "SIGKILL"
config {
image = "openhpi/co_execenv_python:3.8"
command = "sleep"
args = ["infinity"]
}
logs {
max_files = 1
max_file_size = 1
}
resources {
cpu = 40
memory = 40
}
restart {
delay = "0s"
}
}
}
}

14
ci/nomad-run-env-job.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# This script substitutes environment variables in the given Nomad job and runs it afterwards.
if [[ "$#" -ne 2 ]]; then
echo "Usage: $0 path/to/infile path/to/outfile"
fi
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $1 > $2
nomad validate $2
# nomad plan returns 1 if allocations are created or destroyed which is what we want here
# https://www.nomadproject.io/docs/commands/job/plan#usage
nomad plan $2 || [ $? == 1 ]
nomad run $2