-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
273 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,8 @@ func TestAccJob_cmd_nodefilter(t *testing.T) { | |
}, | ||
}) | ||
} | ||
func TestAccJob_cmd_orchestrator(t *testing.T) { | ||
|
||
func TestOchestrator_high_low(t *testing.T) { | ||
var job JobDetail | ||
|
||
resource.Test(t, resource.TestCase{ | ||
|
@@ -78,18 +79,70 @@ func TestAccJob_cmd_orchestrator(t *testing.T) { | |
CheckDestroy: testAccJobCheckDestroy(&job), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccJobConfig_cmd_nodefilter, | ||
Config: testOchestration_high_low, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccJobCheckExists("rundeck_job.test", &job), | ||
func(s *terraform.State) error { | ||
if expected := "subset"; job.Orchestrator.Type != expected { | ||
return fmt.Errorf("wrong subset; expected %v, got %v", expected, job.Orchestrator.Type) | ||
if expected := "basic-job-with-node-filter"; job.Name != expected { | ||
return fmt.Errorf("wrong name; expected %v, got %v", expected, job.Name) | ||
} | ||
if expected := "name: tacobell"; job.CommandSequence.Commands[0].Job.NodeFilter.Query != expected { | ||
return fmt.Errorf("failed to set job node filter; expected %v, got %v", expected, job.CommandSequence.Commands[0].Job.NodeFilter.Query) | ||
} | ||
return nil | ||
}, | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestOchestrator_max_percent(t *testing.T) { | ||
var job JobDetail | ||
|
||
if expected := 1; job.Orchestrator.Config.Count != expected { | ||
return fmt.Errorf("wrong subset count; expected %v, got %v", expected, job.Orchestrator.Config.Count) | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccJobCheckDestroy(&job), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testOchestration_maxperecent, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccJobCheckExists("rundeck_job.test", &job), | ||
func(s *terraform.State) error { | ||
if expected := "basic-job-with-node-filter"; job.Name != expected { | ||
return fmt.Errorf("wrong name; expected %v, got %v", expected, job.Name) | ||
} | ||
if expected := "name: tacobell"; job.CommandSequence.Commands[0].Job.NodeFilter.Query != expected { | ||
return fmt.Errorf("failed to set job node filter; expected %v, got %v", expected, job.CommandSequence.Commands[0].Job.NodeFilter.Query) | ||
} | ||
return nil | ||
}, | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestOchestrator_rankTiered(t *testing.T) { | ||
var job JobDetail | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccJobCheckDestroy(&job), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testOchestration_rank_tiered, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccJobCheckExists("rundeck_job.test", &job), | ||
func(s *terraform.State) error { | ||
if expected := "basic-job-with-node-filter"; job.Name != expected { | ||
return fmt.Errorf("wrong name; expected %v, got %v", expected, job.Name) | ||
} | ||
if expected := "name: tacobell"; job.CommandSequence.Commands[0].Job.NodeFilter.Query != expected { | ||
return fmt.Errorf("failed to set job node filter; expected %v, got %v", expected, job.CommandSequence.Commands[0].Job.NodeFilter.Query) | ||
} | ||
return nil | ||
}, | ||
), | ||
|
@@ -499,3 +552,159 @@ resource "rundeck_job" "test" { | |
} | ||
} | ||
` | ||
|
||
const testOchestration_maxperecent = ` | ||
resource "rundeck_project" "test" { | ||
name = "terraform-acc-test-job" | ||
description = "parent project for job acceptance tests" | ||
resource_model_source { | ||
type = "file" | ||
config = { | ||
format = "resourcexml" | ||
file = "/tmp/terraform-acc-tests.xml" | ||
} | ||
} | ||
} | ||
resource "rundeck_job" "test" { | ||
project_name = "${rundeck_project.test.name}" | ||
name = "orchestrator-MaxPercent" | ||
description = "A basic job" | ||
execution_enabled = true | ||
node_filter_query = "example" | ||
allow_concurrent_executions = true | ||
nodes_selected_by_default = false | ||
max_thread_count = 1 | ||
rank_order = "ascending" | ||
schedule = "0 0 12 * * * *" | ||
schedule_enabled = true | ||
option { | ||
name = "foo" | ||
default_value = "bar" | ||
} | ||
orchestrator { | ||
type = "maxPercentage" | ||
percent = 10 | ||
} | ||
command { | ||
job { | ||
name = "Other Job Name" | ||
run_for_each_node = true | ||
node_filters { | ||
filter = "name: tacobell" | ||
} | ||
} | ||
description = "Prints Hello World" | ||
} | ||
notification { | ||
type = "on_success" | ||
email { | ||
recipients = ["[email protected]"] | ||
} | ||
} | ||
} | ||
` | ||
|
||
const testOchestration_high_low = ` | ||
resource "rundeck_project" "test" { | ||
name = "terraform-acc-test-job" | ||
description = "parent project for job acceptance tests" | ||
resource_model_source { | ||
type = "file" | ||
config = { | ||
format = "resourcexml" | ||
file = "/tmp/terraform-acc-tests.xml" | ||
} | ||
} | ||
} | ||
resource "rundeck_job" "test" { | ||
project_name = "${rundeck_project.test.name}" | ||
name = "orchestrator-High-Low" | ||
description = "A basic job" | ||
execution_enabled = true | ||
node_filter_query = "example" | ||
allow_concurrent_executions = true | ||
nodes_selected_by_default = false | ||
max_thread_count = 1 | ||
rank_order = "ascending" | ||
schedule = "0 0 12 * * * *" | ||
schedule_enabled = true | ||
option { | ||
name = "foo" | ||
default_value = "bar" | ||
} | ||
orchestrator { | ||
type = "orchestrator-highest-lowest-attribute" | ||
sort = "highest" | ||
attribute = "my-attribute" | ||
} | ||
command { | ||
job { | ||
name = "Other Job Name" | ||
run_for_each_node = true | ||
node_filters { | ||
filter = "name: tacobell" | ||
} | ||
} | ||
description = "Prints Hello World" | ||
} | ||
notification { | ||
type = "on_success" | ||
email { | ||
recipients = ["[email protected]"] | ||
} | ||
} | ||
} | ||
` | ||
|
||
const testOchestration_rank_tiered = ` | ||
resource "rundeck_project" "test" { | ||
name = "terraform-acc-test-job" | ||
description = "parent project for job acceptance tests" | ||
resource_model_source { | ||
type = "file" | ||
config = { | ||
format = "resourcexml" | ||
file = "/tmp/terraform-acc-tests.xml" | ||
} | ||
} | ||
} | ||
resource "rundeck_job" "test" { | ||
project_name = "${rundeck_project.test.name}" | ||
name = "basic-job-with-node-filter" | ||
description = "A basic job" | ||
execution_enabled = true | ||
node_filter_query = "example" | ||
allow_concurrent_executions = true | ||
nodes_selected_by_default = false | ||
max_thread_count = 1 | ||
rank_order = "ascending" | ||
schedule = "0 0 12 * * * *" | ||
schedule_enabled = true | ||
option { | ||
name = "foo" | ||
default_value = "bar" | ||
} | ||
orchestrator { | ||
type = "rankTiered" | ||
} | ||
command { | ||
job { | ||
name = "Other Job Name" | ||
run_for_each_node = true | ||
node_filters { | ||
filter = "name: tacobell" | ||
} | ||
} | ||
description = "Prints Hello World" | ||
} | ||
notification { | ||
type = "on_success" | ||
email { | ||
recipients = ["[email protected]"] | ||
} | ||
} | ||
} | ||
` |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters