forked from rundeck/terraform-provider-rundeck
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow overriding of job node filters
- Loading branch information
Showing
3 changed files
with
109 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,33 @@ func TestAccJob_basic(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccJob_cmd_nodefilter(t *testing.T) { | ||
var job JobDetail | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccJobCheckDestroy(&job), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccJobConfig_cmd_nodefilter, | ||
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 TestAccJob_Idempotency(t *testing.T) { | ||
var job JobDetail | ||
|
||
|
@@ -179,6 +206,54 @@ resource "rundeck_job" "test" { | |
} | ||
` | ||
|
||
const testAccJobConfig_cmd_nodefilter = ` | ||
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 | ||
max_thread_count = 1 | ||
rank_order = "ascending" | ||
schedule = "0 0 12 * * * *" | ||
schedule_enabled = true | ||
option { | ||
name = "foo" | ||
default_value = "bar" | ||
} | ||
command { | ||
job { | ||
name = "Other Job Name" | ||
run_for_each_node = true | ||
nodefilters = { | ||
filter: "name: tacobell" | ||
} | ||
} | ||
description = "Prints Hello World" | ||
shell_command = "echo Hello World" | ||
} | ||
notification { | ||
type = "on_success" | ||
email { | ||
recipients = ["[email protected]"] | ||
} | ||
} | ||
} | ||
` | ||
|
||
const testAccJobConfig_noNodeFilterQuery = ` | ||
resource "rundeck_project" "test" { | ||
name = "terraform-acc-test-job-node-filter" | ||
|
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