Skip to content

Commit

Permalink
NS Selector tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinKuli committed Aug 4, 2023
1 parent 377109a commit 6e32ff4
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 123 deletions.
354 changes: 233 additions & 121 deletions test/e2e/case19_ns_selector_test.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/format"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -62,6 +63,8 @@ func init() {
}

var _ = BeforeSuite(func() {
format.TruncatedDiff = false

By("Setup Hub client")
gvrPod = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}
gvrNS = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"}
Expand Down
22 changes: 22 additions & 0 deletions test/resources/case19_ns_selector/case19_behavior_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: selector-behavior-e2e
spec:
evaluationInterval:
compliant: 2h
noncompliant: 2h
namespaceSelector:
exclude:
- "kube-*"
matchExpressions:
- key: case19b
operator: Exists
remediationAction: inform
object-templates:
- complianceType: musthave
objectDefinition:
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-selector-e2e
13 changes: 13 additions & 0 deletions test/resources/case19_ns_selector/case19_behavior_prereq.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Namespace
metadata:
labels:
case19b: case19b-1-e2e
name: case19b-1-e2e
---
apiVersion: v1
kind: Namespace
metadata:
labels:
case19b: case19b-2-e2e
name: case19b-2-e2e
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: policy-configmap-selector-e2e
spec:
namespaceSelector:
matchLabels:
sample: test
remediationAction: inform
evaluationInterval:
compliant: 2h
noncompliant: 2h
object-templates:
- complianceType: musthave
objectDefinition:
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-selector-e2e
2 changes: 2 additions & 0 deletions test/resources/case19_ns_selector/case19_cm_manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ kind: Namespace
metadata:
labels:
name: case19-1-e2e
sample: test
name: case19-1-e2e
---
apiVersion: v1
kind: Namespace
metadata:
labels:
name: case19-2-e2e
sample: test
name: case19-2-e2e
---
apiVersion: v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: policy.open-cluster-management.io/v1
kind: ConfigurationPolicy
metadata:
name: policy-configmap-selector-e2e
name: selector-results-e2e
spec:
namespaceSelector:
include:
- case19-1-e2e
- case19a-1-e2e
remediationAction: inform
object-templates:
- complianceType: musthave
Expand Down
40 changes: 40 additions & 0 deletions test/resources/case19_ns_selector/case19_results_prereq.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: v1
kind: Namespace
metadata:
labels:
case19a: case19a-1-e2e
name: case19a-1-e2e
---
apiVersion: v1
kind: Namespace
metadata:
labels:
case19a: case19a-2-e2e
name: case19a-2-e2e
---
apiVersion: v1
kind: Namespace
metadata:
labels:
case19a: case19a-3-e2e
name: case19a-3-e2e
---
apiVersion: v1
kind: Namespace
metadata:
labels:
case19a: case19a-4-e2e
name: case19a-4-e2e
---
apiVersion: v1
kind: Namespace
metadata:
labels:
case19a: case19a-5-e2e
name: case19a-5-e2e
---
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-selector-e2e
namespace: case19a-1-e2e

0 comments on commit 6e32ff4

Please sign in to comment.