From 09aac6b568903e54594d9bdd258f815d41d0536b Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Fri, 23 Apr 2021 01:15:22 +0100 Subject: [PATCH] Add test --- test/deploy_test.go | 15 +++++ .../fixtures/deploy_fail_with_no_update.nomad | 58 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 test/fixtures/deploy_fail_with_no_update.nomad diff --git a/test/deploy_test.go b/test/deploy_test.go index f30e0e499..20db01fef 100644 --- a/test/deploy_test.go +++ b/test/deploy_test.go @@ -135,6 +135,21 @@ func TestDeploy_canary(t *testing.T) { }) } +func TestDeploy_failed_deploy_with_no_update(t *testing.T) { + acctest.Test(t, acctest.TestCase{ + Steps: []acctest.TestStep{ + { + Runner: acctest.DeployTestStepRunner{ + FixtureName: "deploy_fail_with_no_update.nomad", + }, + ExpectErr: true, + Check: acctest.CheckDeploymentStatus("cancelled"), + }, + }, + CleanupFunc: acctest.CleanupPurgeJob, + }) +} + func TestDeploy_lifecycle(t *testing.T) { acctest.Test(t, acctest.TestCase{ Steps: []acctest.TestStep{ diff --git a/test/fixtures/deploy_fail_with_no_update.nomad b/test/fixtures/deploy_fail_with_no_update.nomad new file mode 100644 index 000000000..6b4a01a33 --- /dev/null +++ b/test/fixtures/deploy_fail_with_no_update.nomad @@ -0,0 +1,58 @@ +job "[[.job_name]]" { + datacenters = ["dc1"] + type = "service" + + group "test" { + count = 1 + + restart { + attempts = 1 + interval = "5s" + delay = "1s" + mode = "fail" + } + + ephemeral_disk { + size = 300 + } + + update { + max_parallel = 1 + min_healthy_time = "10s" + healthy_deadline = "1m" + } + + network { + port "http" { + to = 80 + } + } + + service { + name = "fake-service" + port = "http" + + check { + name = "alive" + type = "tcp" + interval = "10s" + timeout = "2s" + } + } + + task "alpine" { + driver = "docker" + config { + image = "alpine" + command = "sleep 1 && exit 1" + } + resources { + cpu = 100 + memory = 20 + network { + mbits = 10 + } + } + } + } +}