Create demo job when deploying for review

This commit is contained in:
sirkrypto
2021-05-11 15:21:50 +00:00
committed by Tobias Kantusch
parent b141a6870e
commit 24b7f1a2fa
3 changed files with 64 additions and 3 deletions

View File

@ -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

View File

@ -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"
}
}
}
}

View File

@ -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"