Skip to content

Commit aa9fec5

Browse files
authored
feat(ibm): add ibm tests (#287)
* feat(ibm): add ibm tests * feat(ibm): extract common tests in separate workflows
1 parent 504356c commit aa9fec5

File tree

8 files changed

+173
-103
lines changed

8 files changed

+173
-103
lines changed

.github/workflows/ci-master.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,8 @@ jobs:
5555

5656
test:
5757
name: Test
58-
runs-on: ubuntu-latest
59-
60-
steps:
61-
- name: Check out code
62-
uses: actions/checkout@v2
63-
64-
- name: Set up Go
65-
uses: actions/setup-go@v3
66-
with:
67-
go-version: ${{ env.GO_VERSION }}
68-
check-latest: true
69-
cache: true
70-
71-
- name: Get dependencies
72-
run: |
73-
go install github.com/onsi/ginkgo/v2/ginkgo@latest
74-
go mod tidy
75-
76-
- name: Test
77-
run: make test
78-
79-
- name: Acceptance tests
80-
run: make testacc
81-
env:
82-
SYSDIG_MONITOR_API_TOKEN: ${{ secrets.KUBELAB_MONITOR_API_TOKEN }}
83-
SYSDIG_SECURE_API_TOKEN: ${{ secrets.KUBELAB_SECURE_API_TOKEN }}
58+
uses: ./.github/workflows/test.yml
59+
secrets: inherit
8460

8561
lint:
8662
name: Lint

.github/workflows/ci-pull-request.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,8 @@ jobs:
5555

5656
test:
5757
name: Test
58-
runs-on: ubuntu-latest
59-
60-
steps:
61-
- name: Check out code
62-
uses: actions/checkout@v2
63-
64-
- name: Set up Go
65-
uses: actions/setup-go@v3
66-
with:
67-
go-version: ${{ env.GO_VERSION }}
68-
check-latest: true
69-
cache: true
70-
71-
- name: Get dependencies
72-
run: |
73-
go install github.com/onsi/ginkgo/v2/ginkgo@latest
74-
go mod tidy
75-
76-
- name: Test
77-
run: make test
78-
79-
- name: Acceptance tests
80-
run: make testacc
81-
env:
82-
SYSDIG_MONITOR_API_TOKEN: ${{ secrets.KUBELAB_MONITOR_API_TOKEN }}
83-
SYSDIG_SECURE_API_TOKEN: ${{ secrets.KUBELAB_SECURE_API_TOKEN }}
58+
uses: ./.github/workflows/test.yml
59+
secrets: inherit
8460

8561
lint:
8662
name: Lint

.github/workflows/ci-scheduled-tests.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,8 @@ env:
1111
jobs:
1212
test:
1313
name: Test
14-
runs-on: ubuntu-latest
15-
16-
steps:
17-
- name: Check out code
18-
uses: actions/checkout@v2
19-
20-
- name: Set up Go
21-
uses: actions/setup-go@v3
22-
with:
23-
go-version: ${{ env.GO_VERSION }}
24-
check-latest: true
25-
cache: true
26-
27-
- name: Get dependencies
28-
run: |
29-
go install github.com/onsi/ginkgo/v2/ginkgo@latest
30-
go mod tidy
31-
32-
- name: Test
33-
run: make test
34-
35-
- name: Acceptance tests
36-
run: make testacc
37-
env:
38-
SYSDIG_MONITOR_API_TOKEN: ${{ secrets.KUBELAB_MONITOR_API_TOKEN }}
39-
SYSDIG_SECURE_API_TOKEN: ${{ secrets.KUBELAB_SECURE_API_TOKEN }}
14+
uses: ./.github/workflows/test.yml
15+
secrets: inherit
4016

4117
slackNotification:
4218
needs: test

.github/workflows/test.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
name: Unit Tests
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v2
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v3
17+
with:
18+
go-version: ${{ env.GO_VERSION }}
19+
check-latest: true
20+
cache: true
21+
22+
- name: Test
23+
run: make test
24+
25+
test-sysdig:
26+
name: Sysdig Acceptance Tests
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Check out code
31+
uses: actions/checkout@v2
32+
33+
- name: Set up Go
34+
uses: actions/setup-go@v3
35+
with:
36+
go-version: ${{ env.GO_VERSION }}
37+
check-latest: true
38+
cache: true
39+
40+
- name: Test
41+
run: make testacc
42+
env:
43+
SYSDIG_MONITOR_API_TOKEN: ${{ secrets.KUBELAB_MONITOR_API_TOKEN }}
44+
SYSDIG_SECURE_API_TOKEN: ${{ secrets.KUBELAB_SECURE_API_TOKEN }}
45+
46+
test-ibm:
47+
name: IBM Acceptance Tests
48+
runs-on: ubuntu-latest
49+
needs: test
50+
51+
steps:
52+
- name: Check out code
53+
uses: actions/checkout@v2
54+
55+
- name: Set up Go
56+
uses: actions/setup-go@v3
57+
with:
58+
go-version: ${{ env.GO_VERSION }}
59+
check-latest: true
60+
cache: true
61+
62+
- name: Test
63+
run: make testacc-ibm
64+
env:
65+
SYSDIG_IBM_MONITOR_API_KEY: ${{ secrets.TERRAFORM_IBM_API_KEY }}
66+
SYSDIG_IBM_MONITOR_INSTANCE_ID: ${{ secrets.TERRAFORM_IBM_MONITOR_INSTANCE_ID }}
67+
SYSDIG_IBM_MONITOR_URL: "https://us-south.monitoring.test.cloud.ibm.com"
68+
SYSDIG_IBM_MONITOR_IAM_URL: "https://iam.test.cloud.ibm.com"

GNUmakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ test: fmtcheck
3636
testacc: fmtcheck
3737
CGO_ENABLED=1 TF_ACC=1 go test $(TEST) -v $(TESTARGS) -tags=tf_acc_sysdig -timeout 120m -race
3838

39+
testacc-ibm: fmtcheck
40+
CGO_ENABLED=1 TF_ACC=1 go test $(TEST) -v $(TESTARGS) -tags=tf_acc_ibm -timeout 120m -race
41+
3942
junit-report: fmtcheck
4043
@go install github.com/jstemmer/go-junit-report/v2@latest
4144
CGO_ENABLED=1 TF_ACC=1 go test $(TEST) -v $(TESTARGS) -tags=tf_acc_sysdig -timeout 120m -race 2>&1 | go-junit-report -iocopy -out junit-report.xml
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//go:build tf_acc_ibm
2+
3+
package sysdig_test
4+
5+
import (
6+
"fmt"
7+
"os"
8+
"testing"
9+
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
11+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
12+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
13+
14+
"github.com/draios/terraform-provider-sysdig/sysdig"
15+
)
16+
17+
func TestAccMonitorIBMTeam(t *testing.T) {
18+
rText := func() string { return acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) }
19+
20+
resource.ParallelTest(t, resource.TestCase{
21+
PreCheck: func() {
22+
if v := os.Getenv("SYSDIG_IBM_MONITOR_API_KEY"); v == "" {
23+
t.Fatal("SYSDIG_IBM_MONITOR_API_KEY must be set for acceptance tests")
24+
}
25+
},
26+
ProviderFactories: map[string]func() (*schema.Provider, error){
27+
"sysdig": func() (*schema.Provider, error) {
28+
return sysdig.Provider(), nil
29+
},
30+
},
31+
Steps: []resource.TestStep{
32+
{
33+
Config: monitorTeamMinimumConfiguration(rText()),
34+
},
35+
{
36+
Config: monitorTeamWithName(rText()),
37+
},
38+
{
39+
Config: monitorTeamWithFullConfigIBM(rText()),
40+
},
41+
{
42+
ResourceName: "sysdig_monitor_team.sample",
43+
ImportState: true,
44+
ImportStateVerify: true,
45+
},
46+
},
47+
})
48+
}
49+
50+
func monitorTeamWithFullConfigIBM(name string) string {
51+
return fmt.Sprintf(`
52+
resource "sysdig_monitor_team" "sample" {
53+
name = "sample-%s"
54+
description = "%s"
55+
scope_by = "host"
56+
filter = "container.image.repo = \"sysdig/agent\""
57+
can_use_sysdig_capture = true
58+
can_see_infrastructure_events = true
59+
60+
entrypoint {
61+
type = "Dashboards"
62+
}
63+
}`, name, name)
64+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//go:build tf_acc_sysdig || tf_acc_ibm
2+
3+
package sysdig_test
4+
5+
import "fmt"
6+
7+
func monitorTeamMinimumConfiguration(name string) string {
8+
return fmt.Sprintf(`
9+
resource "sysdig_monitor_team" "sample" {
10+
name = "sample-%s"
11+
12+
entrypoint {
13+
type = "Explore"
14+
}
15+
}`, name)
16+
}
17+
18+
func monitorTeamWithName(name string) string {
19+
return fmt.Sprintf(`
20+
resource "sysdig_monitor_team" "sample" {
21+
name = "sample-%s"
22+
description = "%s"
23+
scope_by = "container"
24+
filter = "container.image.repo = \"sysdig/agent\""
25+
26+
entrypoint {
27+
type = "Explore"
28+
}
29+
}`, name, name)
30+
}

sysdig/resource_sysdig_monitor_team_test.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build tf_acc_sysdig
2+
13
package sysdig_test
24

35
import (
@@ -45,31 +47,6 @@ func TestAccMonitorTeam(t *testing.T) {
4547
})
4648
}
4749

48-
func monitorTeamMinimumConfiguration(name string) string {
49-
return fmt.Sprintf(`
50-
resource "sysdig_monitor_team" "sample" {
51-
name = "sample-%s"
52-
53-
entrypoint {
54-
type = "Explore"
55-
}
56-
}`, name)
57-
}
58-
59-
func monitorTeamWithName(name string) string {
60-
return fmt.Sprintf(`
61-
resource "sysdig_monitor_team" "sample" {
62-
name = "sample-%s"
63-
description = "%s"
64-
scope_by = "container"
65-
filter = "container.image.repo = \"sysdig/agent\""
66-
67-
entrypoint {
68-
type = "Explore"
69-
}
70-
}`, name, name)
71-
}
72-
7350
func monitorTeamWithFullConfig(name string) string {
7451
return fmt.Sprintf(`
7552
resource "sysdig_monitor_team" "sample" {

0 commit comments

Comments
 (0)