Skip to content

Commit 0a0905d

Browse files
Merge pull request #30434 from danwinship/servicecidr-4.20
OCPBUGS-46422: Add test that the ServiceCIDR API is blocked [4.20]
2 parents 1d3ad0d + 88f25ed commit 0a0905d

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package networking
2+
3+
import (
4+
g "github.com/onsi/ginkgo/v2"
5+
o "github.com/onsi/gomega"
6+
7+
exutil "github.com/openshift/origin/test/extended/util"
8+
)
9+
10+
var _ = g.Describe("[sig-network] ServiceCIDR", func() {
11+
oc := exutil.NewCLIWithoutNamespace("servicecidr")
12+
13+
g.BeforeEach(func() {
14+
// The VAP is created by CNO, which doesn't run on MicroShift
15+
isMicroshift, err := exutil.IsMicroShiftCluster(oc.AdminKubeClient())
16+
o.Expect(err).NotTo(o.HaveOccurred())
17+
if isMicroshift {
18+
g.Skip("Feature is not currently blocked on Microshift")
19+
}
20+
})
21+
22+
g.It("should be blocked", func() {
23+
g.By("Trying to create a new ServiceCIDR")
24+
yaml := exutil.FixturePath("testdata", "servicecidr.yaml")
25+
err := oc.AsAdmin().Run("create").Args("-f", yaml).Execute()
26+
if err == nil {
27+
// This shouldn't have worked! We'll fail below, but delete the
28+
// ServiceCIDR first because otherwise it may cause spurious
29+
// failures throughout the rest of the test run.
30+
_ = oc.AsAdmin().Run("delete").Args("newcidr1").Execute()
31+
}
32+
o.Expect(err).To(o.HaveOccurred(), "Creating a ServiceCIDR should have been blocked by ValidatingAdmissionPolicy")
33+
34+
g.By("Trying to modify an existing ServiceCIDR")
35+
err = oc.AsAdmin().Run("annotate").Args("servicecidr", "kubernetes", "e2etest=success").Execute()
36+
o.Expect(err).To(o.HaveOccurred(), "Modifying existing ServiceCIDR should have been blocked by ValidatingAdmissionPolicy")
37+
})
38+
})

test/extended/testdata/bindata.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: networking.k8s.io/v1beta1
2+
kind: ServiceCIDR
3+
metadata:
4+
name: newcidr1
5+
spec:
6+
cidrs:
7+
- 10.96.0.0/24

test/extended/util/annotate/generated/zz_generated.annotations.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)