Skip to content

Commit

Permalink
Merge pull request #119 from hashicorp/ossmerge_20190906
Browse files Browse the repository at this point in the history
Ossmerge 20190906
  • Loading branch information
preetapan committed Sep 6, 2019
2 parents cc7c547 + 33c22a0 commit b7dec28
Show file tree
Hide file tree
Showing 7 changed files with 529 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/allocrunner/taskrunner/script_check_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func (h *scriptCheckHook) Update(ctx context.Context, req *interfaces.TaskUpdate
if task == nil {
return fmt.Errorf("task %q not found in updated alloc", h.task.Name)
}
h.alloc = req.Alloc
h.task = task
h.taskEnv = req.TaskEnv

Expand Down
1 change: 1 addition & 0 deletions e2e/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func init() {
Consul: true,
Cases: []framework.TestCase{
new(ConsulE2ETest),
new(ScriptChecksE2ETest),
},
})
}
Expand Down
81 changes: 81 additions & 0 deletions e2e/consul/input/checks_group.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
job "group_check" {
datacenters = ["dc1"]
type = "service"

group "group_check" {
network {
mode = "bridge"
}

service {
name = "group-service-1"
port = "9001"

check {
name = "alive-1"
type = "script"
task = "test"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-1"]
}
}

service {
name = "group-service-2"
port = "9002"

check {
name = "alive-2a"
type = "script"
task = "test"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-2a"]
}

# the file expected by this check will not exist when started,
# so the check will error-out and be in a warning state until
# it's been created
check {
name = "alive-2b"
type = "script"
task = "test"
interval = "2s"
timeout = "2s"
command = "cat"
args = ["${NOMAD_TASK_DIR}/alive-2b"]
}
}

service {
name = "group-service-3"
port = "9003"

# this check should always time out and so the service
# should not be marked healthy
check {
name = "always-dead"
type = "script"
task = "test"
interval = "2s"
timeout = "1s"
command = "sleep"
args = ["10"]
}
}

count = 1

task "test" {
driver = "raw_exec"

config {
command = "bash"
args = ["-c", "sleep 15000"]
}
}
}
}
80 changes: 80 additions & 0 deletions e2e/consul/input/checks_group_update.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
job "group_check" {
datacenters = ["dc1"]
type = "service"

group "group_check" {
network {
mode = "bridge"
}

service {
name = "group-service-1"
port = "9001"

# after update, check name has changed
check {
name = "alive-1a"
type = "script"
task = "test"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-1a"]
}
}

service {
name = "group-service-2"
port = "9002"

check {
name = "alive-2a"
type = "script"
task = "test"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-2a"]
}

# after updating, this check will always pass
check {
name = "alive-2b"
type = "script"
task = "test"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-2b"]
}
}

service {
name = "group-service-3"
port = "9003"

# this check should always time out and so the service
# should not be marked healthy
check {
name = "always-dead"
type = "script"
task = "test"
interval = "2s"
timeout = "1s"
command = "sleep"
args = ["10"]
}
}

count = 1

task "test" {
driver = "raw_exec"

config {
command = "bash"
args = ["-c", "sleep 15000"]
}
}
}
}
70 changes: 70 additions & 0 deletions e2e/consul/input/checks_task.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
job "task_check" {
datacenters = ["dc1"]
type = "service"

group "task_check" {
count = 1

task "test" {
service {
name = "task-service-1"

check {
name = "alive-1"
type = "script"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-1"]
}
}

service {
name = "task-service-2"

check {
name = "alive-2a"
type = "script"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-2a"]
}

# the file expected by this check will not exist when started,
# so the check will error-out and be in a warning state until
# it's been created
check {
name = "alive-2b"
type = "script"
interval = "2s"
timeout = "2s"
command = "cat"
args = ["${NOMAD_TASK_DIR}/alive-2b"]
}
}

service {
name = "task-service-3"

# this check should always time out and so the service
# should not be marked healthy
check {
name = "always-dead"
type = "script"
interval = "2s"
timeout = "1s"
command = "sleep"
args = ["10"]
}
}

driver = "raw_exec"

config {
command = "bash"
args = ["-c", "sleep 15000"]
}
}
}
}
73 changes: 73 additions & 0 deletions e2e/consul/input/checks_task_update.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
job "task_check" {
datacenters = ["dc1"]
type = "service"

group "task_check" {
count = 1

task "test" {
service {
name = "task-service-1"

# after update, check name has changed
check {
name = "alive-1a"
type = "script"
task = "test"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-1a"]
}
}

service {
name = "task-service-2"

check {
name = "alive-2a"
type = "script"
task = "test"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-2a"]
}

# after updating, this check will always pass
check {
name = "alive-2b"
type = "script"
task = "test"
interval = "2s"
timeout = "2s"
command = "echo"
args = ["alive-2b"]
}
}

service {
name = "task-service-3"

# this check should always time out and so the service
# should not be marked healthy
check {
name = "always-dead"
type = "script"
task = "test"
interval = "2s"
timeout = "1s"
command = "sleep"
args = ["10"]
}
}

driver = "raw_exec"

config {
command = "bash"
args = ["-c", "sleep 15000"]
}
}
}
}
Loading

0 comments on commit b7dec28

Please sign in to comment.