Skip to content

Commit 7963442

Browse files
committed
Use testcase-scoped variables
Signed-off-by: Dale Haiducek <[email protected]>
1 parent 6efa4c0 commit 7963442

16 files changed

+137
-141
lines changed

test/e2e/case10_policyset_propagation_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ import (
1717
"open-cluster-management.io/governance-policy-propagator/test/utils"
1818
)
1919

20-
const (
21-
path string = "../resources/case10_policyset_propagation/"
22-
case10PolicyName string = "case10-test-policy"
23-
case10PolicySetName string = "case10-test-policyset"
24-
case10PolicySetYaml string = path + "case10-test-policyset.yaml"
25-
case10PolicySetPlacementYaml string = path + "case10-test-policyset-placement.yaml"
26-
case10PolicySetPolicyYaml string = path + "case10-test-policyset-policy.yaml"
27-
case10PolicySetPolicyPlacementYaml string = path + "case10-test-policyset-policy-placement.yaml"
28-
)
29-
3020
var _ = Describe("Test policyset propagation", func() {
21+
const (
22+
path string = "../resources/case10_policyset_propagation/"
23+
case10PolicyName string = "case10-test-policy"
24+
case10PolicySetName string = "case10-test-policyset"
25+
case10PolicySetYaml string = path + "case10-test-policyset.yaml"
26+
case10PolicySetPlacementYaml string = path + "case10-test-policyset-placement.yaml"
27+
case10PolicySetPolicyYaml string = path + "case10-test-policyset-policy.yaml"
28+
case10PolicySetPolicyPlacementYaml string = path + "case10-test-policyset-policy-placement.yaml"
29+
)
30+
3131
Describe("Test policy propagation through policyset placementbinding with placementrule", func() {
3232
It("should be created in user ns", func() {
3333
By("Creating " + case10PolicySetYaml)

test/e2e/case11_policyset_controller_test.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,27 @@ import (
1515
"open-cluster-management.io/governance-policy-propagator/test/utils"
1616
)
1717

18-
const (
19-
case11PolicyName string = "case11-test-policy"
20-
case11PolicySetName string = "case11-test-policyset"
21-
case11PolicySetNameManaged1 string = "test-plcset-managed1"
22-
case11PolicyNameManaged2 string = "case11-multiple-placements-rule"
23-
case11PolicySetEmpty string = "case11-empty-policyset"
24-
case11PolicySetMultiStatus string = "case11-multistatus-policyset"
25-
case11PolicyCompliant string = "case11-compliant-plc"
26-
case11PolicyYaml string = "../resources/case11_policyset_controller/case11-test-policy.yaml"
27-
case11PolicySetPatchYaml string = "../resources/case11_policyset_controller/case11-patch-plcset.yaml"
28-
case11PolicySetPatch2Yaml string = "../resources/case11_policyset_controller/case11-patch-plcset-2.yaml"
29-
case11DisablePolicyYaml string = "../resources/case11_policyset_controller/case11-disable-plc.yaml"
30-
case11PolicySetManaged1Yaml string = "../resources/case11_policyset_controller/case11-plcset-managed1.yaml"
31-
case11PolicyManaged2Yaml string = "../resources/case11_policyset_controller/case11-plc-managed2.yaml"
32-
case11PolicySetEmptyYaml string = "../resources/case11_policyset_controller/case11-empty-plcset.yaml"
33-
case11PolicySetMultiStatusYaml string = "../resources/case11_policyset_controller/case11-plcset-multistatus.yaml"
34-
case11PolicyCompliantYaml string = "../resources/case11_policyset_controller/case11-compliant-plc.yaml"
35-
)
36-
3718
var _ = Describe("Test policyset controller status updates", func() {
19+
const (
20+
case11PolicyName string = "case11-test-policy"
21+
case11PolicySetName string = "case11-test-policyset"
22+
case11PolicySetNameManaged1 string = "test-plcset-managed1"
23+
case11PolicyNameManaged2 string = "case11-multiple-placements-rule"
24+
case11PolicySetEmpty string = "case11-empty-policyset"
25+
case11PolicySetMultiStatus string = "case11-multistatus-policyset"
26+
case11PolicyCompliant string = "case11-compliant-plc"
27+
case11Path string = "../resources/case11_policyset_controller/"
28+
case11PolicyYaml string = case11Path + "case11-test-policy.yaml"
29+
case11PolicySetPatchYaml string = case11Path + "case11-patch-plcset.yaml"
30+
case11PolicySetPatch2Yaml string = case11Path + "case11-patch-plcset-2.yaml"
31+
case11DisablePolicyYaml string = case11Path + "case11-disable-plc.yaml"
32+
case11PolicySetManaged1Yaml string = case11Path + "case11-plcset-managed1.yaml"
33+
case11PolicyManaged2Yaml string = case11Path + "case11-plc-managed2.yaml"
34+
case11PolicySetEmptyYaml string = case11Path + "case11-empty-plcset.yaml"
35+
case11PolicySetMultiStatusYaml string = case11Path + "case11-plcset-multistatus.yaml"
36+
case11PolicyCompliantYaml string = case11Path + "case11-compliant-plc.yaml"
37+
)
38+
3839
Describe("Create policy, policyset, and placement in ns:"+testNamespace, func() {
3940
It("should create and process policy and policyset", func() {
4041
By("Creating " + case11PolicyYaml)

test/e2e/case12_encryptionkeys_controller_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ import (
1919
"open-cluster-management.io/governance-policy-propagator/test/utils"
2020
)
2121

22-
const (
23-
EncryptionKeySecret = "policy-encryption-key"
24-
LastRotatedAnnotation = "policy.open-cluster-management.io/last-rotated"
25-
RootPolicyLabel = "policy.open-cluster-management.io/root-policy"
26-
TriggerUpdateAnnotation = "policy.open-cluster-management.io/trigger-update"
27-
)
28-
2922
var _ = Describe("Test policy encryption key rotation", func() {
3023
key := bytes.Repeat([]byte{byte('A')}, 256/8)
3124
keyB64 := base64.StdEncoding.EncodeToString(key)

test/e2e/case14_root_policy_metrics_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import (
1717

1818
var _ = Describe("Test root policy metrics", Ordered, func() {
1919
const (
20-
policyName = "case9-test-policy"
21-
policyYaml = "../resources/case9_templates/case9-test-policy.yaml"
20+
policyName = "case9-test-policy"
21+
policyYaml = "../resources/case9_templates/case9-test-policy.yaml"
22+
replicatedPolicyYaml = "../resources/case9_templates/case9-test-replpolicy-managed1.yaml"
2223
)
2324

2425
Describe("Create policy, placement and referenced resource in ns:"+testNamespace, func() {
@@ -63,7 +64,7 @@ var _ = Describe("Test root policy metrics", Ordered, func() {
6364
)
6465
Expect(plc).ToNot(BeNil())
6566

66-
yamlPlc := utils.ParseYaml(case9ReplicatedPolicyYamlM1)
67+
yamlPlc := utils.ParseYaml(replicatedPolicyYaml)
6768
Eventually(func(g Gomega) interface{} {
6869
replicatedPlc := utils.GetWithTimeout(
6970
clientHubDynamic,

test/e2e/case17_policy_webhook_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ import (
1414
"open-cluster-management.io/governance-policy-propagator/test/utils"
1515
)
1616

17-
const (
18-
case17Prefix string = "../resources/case17_policy_webhook/"
19-
case17PolicyLongYaml string = case17Prefix + "case17_policy_long.yaml"
20-
case17PolicyReplicatedYaml string = case17Prefix + "case17_policy_replicate.yaml"
21-
case17PolicyRemediationYaml string = case17Prefix + "case17_invalid_remediation_policy.yaml"
22-
case17PolicyRootRemediationYaml string = case17Prefix + "case17_valid_remediation_policy_root.yaml"
23-
case17PolicyCfplcRemediationYaml string = case17Prefix + "case17_valid_remediation_policy_cfplc.yaml"
24-
longNamespace string = "long-long-long-long-long-long-long"
25-
case17PolicyReplicatedName string = "case17-test-policy-replicated-longlong"
26-
case17PolicyReplicatedPlr string = "case17-test-policy-replicated-longlong-plr"
27-
case17PolicyReplicatedPb string = "case17-test-policy-replicated-longlong-pb"
28-
case17PolicyRemediationName string = "case17-test-policy-no-remediation"
29-
case17PolicyRootRemediationName string = "case17-test-policy-root-remediation"
30-
case17PolicyCfplcRemediationName string = "case17-test-policy-cfplc-remediation"
31-
errPrefix string = `admission webhook "policy.open-cluster-management.io.webhook" ` +
32-
`denied the request: `
33-
combinedLengthErr string = errPrefix + "the combined length of the policy namespace and name " +
34-
"cannot exceed 62 characters"
35-
remediationErr string = errPrefix + "RemediationAction field of the policy and policy template " +
36-
"cannot both be unset"
37-
)
38-
3917
var _ = Describe("Test policy webhook", Label("webhook"), Ordered, func() {
18+
const (
19+
case17Prefix string = "../resources/case17_policy_webhook/"
20+
case17PolicyLongYaml string = case17Prefix + "case17_policy_long.yaml"
21+
case17PolicyReplicatedYaml string = case17Prefix + "case17_policy_replicate.yaml"
22+
case17PolicyRemediationYaml string = case17Prefix + "case17_invalid_remediation_policy.yaml"
23+
case17PolicyRootRemediationYaml string = case17Prefix + "case17_valid_remediation_policy_root.yaml"
24+
case17PolicyCfplcRemediationYaml string = case17Prefix + "case17_valid_remediation_policy_cfplc.yaml"
25+
longNamespace string = "long-long-long-long-long-long-long"
26+
case17PolicyReplicatedName string = "case17-test-policy-replicated-longlong"
27+
case17PolicyReplicatedPlr string = "case17-test-policy-replicated-longlong-plr"
28+
case17PolicyReplicatedPb string = "case17-test-policy-replicated-longlong-pb"
29+
case17PolicyRemediationName string = "case17-test-policy-no-remediation"
30+
case17PolicyRootRemediationName string = "case17-test-policy-root-remediation"
31+
case17PolicyCfplcRemediationName string = "case17-test-policy-cfplc-remediation"
32+
errPrefix string = `admission webhook "policy.open-cluster-management.io.webhook" ` +
33+
`denied the request: `
34+
combinedLengthErr string = errPrefix + "the combined length of the policy namespace and name " +
35+
"cannot exceed 62 characters"
36+
remediationErr string = errPrefix + "RemediationAction field of the policy and policy template " +
37+
"cannot both be unset"
38+
)
39+
4040
Describe("Test name + namespace over 63", func() {
4141
BeforeAll(func() {
4242
_, err := utils.KubectlWithOutput("create",

test/e2e/case19_rep_policy_placement_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"open-cluster-management.io/governance-policy-propagator/test/utils"
1212
)
1313

14-
const (
15-
case19PolicyName string = "case19-test-policy"
16-
case19PolicyYaml string = "../resources/case19_rep_policy_placement/case19-test-policy.yaml"
17-
)
18-
1914
var _ = Describe("Test replicated_policy controller and propagation", Ordered, Serial, func() {
15+
const (
16+
case19PolicyName string = "case19-test-policy"
17+
case19PolicyYaml string = "../resources/case19_rep_policy_placement/case19-test-policy.yaml"
18+
)
19+
2020
BeforeAll(func() {
2121
By("Creating " + case19PolicyName)
2222
utils.Kubectl("apply",

test/e2e/case1_propagation_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222
"open-cluster-management.io/governance-policy-propagator/test/utils"
2323
)
2424

25-
const (
26-
case1PolicyName string = "case1-test-policy"
27-
case1PolicyYaml string = "../resources/case1_propagation/case1-test-policy.yaml"
28-
)
29-
3025
var _ = Describe("Test policy propagation", func() {
26+
const (
27+
case1PolicyName string = "case1-test-policy"
28+
case1PolicyYaml string = "../resources/case1_propagation/case1-test-policy.yaml"
29+
)
30+
3131
Describe("Test event emission when policy is disabled", Ordered, func() {
3232
BeforeAll(func() {
3333
By("Creating the policy, placementrule, and placementbinding")

test/e2e/case20_compliance_api_controller_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ import (
3535
"open-cluster-management.io/governance-policy-propagator/test/utils"
3636
)
3737

38-
const (
39-
case20PolicyName string = "case20-policy"
40-
case20PolicyYAML string = "../resources/case20_compliance_api_controller/policy.yaml"
41-
)
42-
4338
var _ = Describe("Test governance-policy-database secret changes and DB annotations", Serial, Ordered, func() {
39+
const (
40+
case20PolicyName string = "case20-policy"
41+
case20PolicyYAML string = "../resources/case20_compliance_api_controller/policy.yaml"
42+
)
43+
4444
seededRand := rand.New(rand.NewSource(time.Now().UnixNano()))
4545
nsName := fmt.Sprintf("case20-%d", seededRand.Int31())
4646

test/e2e/case3_mutation_recovery_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import (
1616
"open-cluster-management.io/governance-policy-propagator/test/utils"
1717
)
1818

19-
const (
20-
case3PolicyName string = "case3-test-policy"
21-
case3PolicyYaml string = "../resources/case3_mutation_recovery/case3-test-policy.yaml"
22-
)
23-
2419
var _ = Describe("Test unexpected policy mutation", func() {
20+
const (
21+
case3PolicyName string = "case3-test-policy"
22+
case3PolicyYaml string = "../resources/case3_mutation_recovery/case3-test-policy.yaml"
23+
)
24+
2525
BeforeEach(func() {
2626
By("Creating " + case3PolicyYaml)
2727
utils.Kubectl("apply",

test/e2e/case4_unexpected_policy_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"open-cluster-management.io/governance-policy-propagator/test/utils"
1212
)
1313

14-
const (
15-
case4PolicyName string = "case4-test-policy"
16-
case4PolicyYaml string = "../resources/case4_unexpected_policy/case4-test-policy.yaml"
17-
)
18-
1914
var _ = Describe("Test unexpect policy handling", func() {
15+
const (
16+
case4PolicyName string = "case4-test-policy"
17+
case4PolicyYaml string = "../resources/case4_unexpected_policy/case4-test-policy.yaml"
18+
)
19+
2020
It("Unexpected root policy in cluster namespace should be deleted", func() {
2121
By("Creating " + case4PolicyYaml + "in cluster namespace: managed1")
2222
out, err := utils.KubectlWithOutput("apply",

test/e2e/case5_policy_automation_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ import (
2020
"open-cluster-management.io/governance-policy-propagator/test/utils"
2121
)
2222

23-
const (
24-
case5PolicyName string = "case5-test-policy"
25-
case5PolicyYaml string = "../resources/case5_policy_automation/case5-test-policy.yaml"
26-
)
27-
28-
const automationName string = "create-service.now-ticket"
29-
3023
var _ = Describe("Test policy automation", Label("policyautomation"), Ordered, func() {
24+
const (
25+
case5PolicyName string = "case5-test-policy"
26+
case5PolicyYaml string = "../resources/case5_policy_automation/case5-test-policy.yaml"
27+
automationName string = "create-service.now-ticket"
28+
)
29+
3130
ansiblelistlen := 0
3231
// Use this only when target_clusters managed1 managed2 managed3
3332
getLastAnsiblejob := func() *unstructured.Unstructured {

test/e2e/case6_placement_propagation_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import (
1515
"open-cluster-management.io/governance-policy-propagator/test/utils"
1616
)
1717

18-
const (
19-
case6PolicyName string = "case6-test-policy"
20-
case6PolicyYaml string = "../resources/case6_placement_propagation/case6-test-policy.yaml"
21-
)
22-
2318
var _ = Describe("Test policy propagation", func() {
19+
const (
20+
case6PolicyName string = "case6-test-policy"
21+
case6PolicyYaml string = "../resources/case6_placement_propagation/case6-test-policy.yaml"
22+
)
23+
2424
Describe("Create policy/pb/plc in ns:"+testNamespace+" and then update pb/plc", Ordered, func() {
2525
BeforeAll(func() {
2626
By("Creating " + case6PolicyYaml)

test/e2e/case7_bindings_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ import (
1515
"open-cluster-management.io/governance-policy-propagator/test/utils"
1616
)
1717

18-
const (
19-
case7PolicyName string = "case7-test-policy"
20-
case7PolicyYaml string = "../resources/case7_placement_bindings/case7-test-policy.yaml"
21-
case7BindingYaml1 string = "../resources/case7_placement_bindings/case7-test-binding1.yaml"
22-
case7BindingYaml2 string = "../resources/case7_placement_bindings/case7-test-binding2.yaml"
23-
case7BindingYaml3 string = "../resources/case7_placement_bindings/case7-test-binding3.yaml"
24-
case7BindingYaml4 string = "../resources/case7_placement_bindings/case7-test-binding4.yaml"
25-
)
26-
2718
var _ = Describe("Test policy propagation", func() {
19+
const (
20+
case7PolicyName string = "case7-test-policy"
21+
case7PolicyYaml string = "../resources/case7_placement_bindings/case7-test-policy.yaml"
22+
case7BindingYaml1 string = "../resources/case7_placement_bindings/case7-test-binding1.yaml"
23+
case7BindingYaml2 string = "../resources/case7_placement_bindings/case7-test-binding2.yaml"
24+
case7BindingYaml3 string = "../resources/case7_placement_bindings/case7-test-binding3.yaml"
25+
case7BindingYaml4 string = "../resources/case7_placement_bindings/case7-test-binding4.yaml"
26+
)
27+
2828
Describe("Create policy/pb/plc in ns:"+testNamespace, Ordered, func() {
2929
BeforeAll(func() {
3030
By("Creating " + case7PolicyYaml)

test/e2e/case8_metrics_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import (
1414
"open-cluster-management.io/governance-policy-propagator/test/utils"
1515
)
1616

17-
const (
18-
case8PolicyName string = "case8-test-policy"
19-
case8PolicyYaml string = "../resources/case8_metrics/case8-test-policy.yaml"
20-
)
21-
2217
var _ = Describe("Test metrics appear locally", func() {
18+
const (
19+
case8PolicyName string = "case8-test-policy"
20+
case8PolicyYaml string = "../resources/case8_metrics/case8-test-policy.yaml"
21+
)
22+
2323
It("should report 0 for compliant root policy and replicated policies", func() {
2424
By("Creating " + case8PolicyYaml)
2525
utils.Kubectl("apply",

0 commit comments

Comments
 (0)