From ee522ab587cd5efc797ac39697fd0a179afa3cff Mon Sep 17 00:00:00 2001 From: Jasmine Dahilig Date: Tue, 18 Aug 2020 10:49:50 -0700 Subject: [PATCH] task lifecycle: e2e tests --- e2e/e2e_test.go | 1 + e2e/lifecycle/inputs/batch.nomad | 127 +++++++++++++++++++++++ e2e/lifecycle/inputs/service.nomad | 160 +++++++++++++++++++++++++++++ e2e/lifecycle/lifecycle.go | 115 +++++++++++++++++++++ 4 files changed, 403 insertions(+) create mode 100644 e2e/lifecycle/inputs/batch.nomad create mode 100644 e2e/lifecycle/inputs/service.nomad create mode 100644 e2e/lifecycle/lifecycle.go diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 0b0f024cf..f8d4032d3 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -17,6 +17,7 @@ import ( _ "github.com/hashicorp/nomad/e2e/deployment" _ "github.com/hashicorp/nomad/e2e/example" _ "github.com/hashicorp/nomad/e2e/hostvolumes" + _ "github.com/hashicorp/nomad/e2e/lifecycle" _ "github.com/hashicorp/nomad/e2e/metrics" _ "github.com/hashicorp/nomad/e2e/nomad09upgrade" _ "github.com/hashicorp/nomad/e2e/nomadexec" diff --git a/e2e/lifecycle/inputs/batch.nomad b/e2e/lifecycle/inputs/batch.nomad new file mode 100644 index 000000000..744bcf7b6 --- /dev/null +++ b/e2e/lifecycle/inputs/batch.nomad @@ -0,0 +1,127 @@ +# lifecycle hook test job for batch jobs. touches, removes, and tests +# for the existence of files to assert the order of running tasks. +# all tasks should exit 0 and the alloc dir should contain the following +# files: ./init-ran, ./main-ran, ./poststart-run + +job "batch-lifecycle" { + + datacenters = ["dc1"] + + type = "batch" + + group "test" { + + task "init" { + + lifecycle { + hook = "prestart" + } + + driver = "docker" + + config { + image = "busybox:1" + command = "/bin/sh" + args = ["local/prestart.sh"] + } + + template { + data = <