diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 964d399..ee4f262 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -115,7 +115,7 @@ test_e2e: - nomad agent -dev -log-level=WARN & - sleep 5 # Setup Nomad job and wait for it - - nomad run ci/python.nomad + - nomad run ci/e2e-test.nomad - sleep 5 # Start Poseidon and wait for it - ./poseidon & @@ -130,9 +130,10 @@ test_e2e: - job: dockerimage artifacts: false - test_e2e - script: + before_script: - export NOMAD_NAMESPACE="$NOMAD_SLUG" - nomad namespace apply $NOMAD_NAMESPACE + script: # Only replace set env vars - envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < ci/api.tpl.nomad > ci/api.nomad # Make sure to set NOMAD_ADDR, NOMAD_SKIP_VERIFY and NOMAD_TOKEN env vars in CI settings appropriately @@ -154,6 +155,13 @@ deploy_review: name: $CI_COMMIT_REF_SLUG url: http://$CI_ENVIRONMENT_SLUG.$BASE_DOMAIN on_stop: stop_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 only: - branches - tags diff --git a/ci/deploy-review.tpl.nomad b/ci/deploy-review.tpl.nomad new file mode 100644 index 0000000..0d3bc0e --- /dev/null +++ b/ci/deploy-review.tpl.nomad @@ -0,0 +1,52 @@ +// 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" + } + } + } +} diff --git a/ci/python.nomad b/ci/e2e-test.nomad similarity index 94% rename from ci/python.nomad rename to ci/e2e-test.nomad index 6bfd788..3693e8d 100644 --- a/ci/python.nomad +++ b/ci/e2e-test.nomad @@ -1,4 +1,5 @@ -// ToDo: Delete when creating job on test startup #26. +// This job is used by the e2e tests as a demo job. + job "python" { datacenters = ["dc1"] type = "batch"