@@ -123,10 +123,18 @@ func TestClusterOperatorStatusRelatedObjects(t *testing.T) {
123123 Resource : "dnses" ,
124124 Name : "default" ,
125125 },
126+ {
127+ Resource : "networkpolicies" ,
128+ Namespace : "openshift-dns-operator" ,
129+ },
126130 {
127131 Resource : "namespaces" ,
128132 Name : "openshift-dns" ,
129133 },
134+ {
135+ Resource : "networkpolicies" ,
136+ Namespace : "openshift-dns" ,
137+ },
130138 }
131139 err = wait .PollImmediate (1 * time .Second , 5 * time .Minute , func () (bool , error ) {
132140 co := & configv1.ClusterOperator {}
@@ -533,6 +541,17 @@ func TestDNSForwarding(t *testing.T) {
533541 t .Fatalf ("version %s not found for clusteroperator %s" , statuscontroller .CoreDNSVersionName , opName )
534542 }
535543
544+ // Create the test pod network policy.
545+ testPodNetworkPolicy := buildTestPodNetworkPolicy (types.NamespacedName {Name : "test-upstream-allow" , Namespace : upstreamPodNs })
546+ if err := cl .Create (context .TODO (), testPodNetworkPolicy ); err != nil {
547+ t .Fatalf ("failed to create network policy %s/%s: %v" , testPodNetworkPolicy .Namespace , testPodNetworkPolicy .Name , err )
548+ }
549+ defer func () {
550+ if err := cl .Delete (context .TODO (), testPodNetworkPolicy ); err != nil {
551+ t .Fatalf ("failed to delete network policy %s/%s: %v" , testPodNetworkPolicy .Namespace , testPodNetworkPolicy .Name , err )
552+ }
553+ }()
554+
536555 // Create the upstream resolver Pod.
537556 upstreamResolver := upstreamPod (upstreamPodName , upstreamPodNs , coreImage , upstreamPodName )
538557 if err := cl .Create (context .TODO (), upstreamResolver ); err != nil {
@@ -804,6 +823,17 @@ func TestDNSOverTLSForwarding(t *testing.T) {
804823 t .Fatalf ("version %s not found for clusteroperator %s" , statuscontroller .OpenshiftCLIVersionName , opName )
805824 }
806825
826+ // Create the test pod network policy.
827+ testPodNetworkPolicy := buildTestPodNetworkPolicy (types.NamespacedName {Name : "test-upstream-tls-allow" , Namespace : upstreamPodNs })
828+ if err := cl .Create (context .TODO (), testPodNetworkPolicy ); err != nil {
829+ t .Fatalf ("failed to create network policy %s/%s: %v" , testPodNetworkPolicy .Namespace , testPodNetworkPolicy .Name , err )
830+ }
831+ defer func () {
832+ if err := cl .Delete (context .TODO (), testPodNetworkPolicy ); err != nil {
833+ t .Fatalf ("failed to delete network policy %s/%s: %v" , testPodNetworkPolicy .Namespace , testPodNetworkPolicy .Name , err )
834+ }
835+ }()
836+
807837 // Create the upstream resolver Pods and the client pod
808838 upstreamResolver := upstreamTLSPod (tlsUpstreamName , tlsUpstreamNamespace .Name , coreImage , upstreamTLSConfigMap )
809839 if err := cl .Create (context .TODO (), upstreamResolver ); err != nil {
0 commit comments