Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more examples and test cases for Atracker #4645

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions ibm/service/atracker/resource_ibm_atracker_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,38 @@ func TestAccIBMAtrackerRouteBasic(t *testing.T) {
})
}

func TestAccIBMAtrackerRouteBasicMultipleRules(t *testing.T) {
var conf atrackerv2.Route
name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100))
nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100))

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIBMAtrackerRouteDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMAtrackerRouteConfigBasicMultipleRules(name),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckIBMAtrackerRouteExists("ibm_atracker_route.atracker_route", conf),
resource.TestCheckResourceAttr("ibm_atracker_route.atracker_route", "name", name),
),
},
{
Config: testAccCheckIBMAtrackerRouteConfigBasicMultipleRules(nameUpdate),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("ibm_atracker_route.atracker_route", "name", nameUpdate),
),
},
{
ResourceName: "ibm_atracker_route.atracker_route",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccCheckIBMAtrackerRouteConfigBasic(name string) string {
return fmt.Sprintf(`
resource "ibm_atracker_target" "atracker_target" {
Expand All @@ -71,6 +103,33 @@ func testAccCheckIBMAtrackerRouteConfigBasic(name string) string {
`, name)
}

func testAccCheckIBMAtrackerRouteConfigBasicMultipleRules(name string) string {
return fmt.Sprintf(`
resource "ibm_atracker_target" "atracker_target" {
name = "my-cos-target"
target_type = "cloud_object_storage"
cos_endpoint {
endpoint = "s3.private.us-east.cloud-object-storage.appdomain.cloud"
target_crn = "crn:v1:bluemix:public:cloud-object-storage:global:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::"
bucket = "my-atracker-bucket"
api_key = "xxxxxxxxxxxxxx"
}
}

resource "ibm_atracker_route" "atracker_route" {
name = "%s"
rules {
target_ids = [ ibm_atracker_target.atracker_target.id ]
locations = [ "us-south" ]
}
rules {
target_ids = [ ibm_atracker_target.atracker_target.id ]
locations = [ "us-east" ]
}
}
`, name)
}

func testAccCheckIBMAtrackerRouteExists(n string, obj atrackerv2.Route) resource.TestCheckFunc {

return func(s *terraform.State) error {
Expand Down
21 changes: 21 additions & 0 deletions website/docs/r/atracker_route.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Provides a resource for Activity Tracker Route. This allows Activity Tracker Rou

## Example usage

### Example with a single rule
```terraform
resource "ibm_atracker_route" "atracker_route" {
name = "my-route"
Expand All @@ -26,6 +27,26 @@ resource "ibm_atracker_route" "atracker_route" {
}
```

### Example with multiple rules

```terraform
resource "ibm_atracker_route" "atracker_route" {
name = "my-route"
rules {
target_ids = [ ibm_atracker_target.atracker_target.id ]
locations = [ "us-south", "global" ]
}
rules {
target_ids = [ ibm_atracker_target.atracker_target.id ]
locations = [ "us-east" ]
}
lifecycle {
# Recommended to ensure that if a target ID is removed here and destroyed in a plan, this is updated first
create_before_destroy = true
}
}
```

## Argument reference

Review the argument reference that you can specify for your resource.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/atracker_settings.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Review the argument reference that you can specify for your resource.
* Constraints: The list items must match regular expression `/^[a-zA-Z0-9 -]/`.
* `metadata_region_primary` - (Required, String) To store all your meta data in a single region.
* Constraints: The maximum length is `256` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -_]/`.
* `metadata_region_primary` - (Optional, String) To store all your meta data in a backup region.
* `metadata_region_backup` - (Optional, String) To store all your meta data in a backup region.
* Constraints: The maximum length is `256` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -_]/`.
* `permitted_target_regions` - (Optional, List) If present then only these regions may be used to define a target.
* Constraints: The list items must match regular expression `/^[a-zA-Z0-9 -_]/`.
Expand Down
6 changes: 3 additions & 3 deletions website/docs/r/atracker_target.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ resource "ibm_atracker_target" "atracker_eventstreams_target" {
target_type = "event_streams"
eventstreams_endpoint {
target_crn = "crn:v1:bluemix:public:logdna:us-south:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::"
"brokers": ["xxxxx.cloud.ibm.com:9093","yyyyy.cloud.ibm.com:9093"]
"topic": "my-topic"
"api_key": "api-key" // pragma: allowlist secret
brokers = ["xxxxx.cloud.ibm.com:9093","yyyyy.cloud.ibm.com:9093"]
topic = "my-topic"
api_key = "api-key" // pragma: allowlist secret
}
name = "my-eventstreams-target"
target_type = "event_streams"
Expand Down