Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions test/extended/networking/servicecidr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package networking

import (
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"

exutil "github.com/openshift/origin/test/extended/util"
)

var _ = g.Describe("[sig-network] ServiceCIDR", func() {
oc := exutil.NewCLIWithoutNamespace("servicecidr")

g.BeforeEach(func() {
// The VAP is created by CNO, which doesn't run on MicroShift
isMicroshift, err := exutil.IsMicroShiftCluster(oc.AdminKubeClient())
o.Expect(err).NotTo(o.HaveOccurred())
if isMicroshift {
g.Skip("Feature is not currently blocked on Microshift")
}
})

g.It("should be blocked", func() {
g.By("Trying to create a new ServiceCIDR")
yaml := exutil.FixturePath("testdata", "servicecidr.yaml")
err := oc.AsAdmin().Run("create").Args("-f", yaml).Execute()
if err == nil {
// This shouldn't have worked! We'll fail below, but delete the
// ServiceCIDR first because otherwise it may cause spurious
// failures throughout the rest of the test run.
_ = oc.AsAdmin().Run("delete").Args("newcidr1").Execute()
}
o.Expect(err).To(o.HaveOccurred(), "Creating a ServiceCIDR should have been blocked by ValidatingAdmissionPolicy")

g.By("Trying to modify an existing ServiceCIDR")
err = oc.AsAdmin().Run("annotate").Args("servicecidr", "kubernetes", "e2etest=success").Execute()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my understanding, I assume this is created by default in k8s, is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the kubernetes ServiceCIDR is created by the apiserver, just like the kubernetes Service.

o.Expect(err).To(o.HaveOccurred(), "Modifying existing ServiceCIDR should have been blocked by ValidatingAdmissionPolicy")
})
})
27 changes: 27 additions & 0 deletions test/extended/testdata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/extended/testdata/servicecidr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: networking.k8s.io/v1beta1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have a v1 resource in 4.20?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yes... I must have copied this example from old docs or something. Anyway, specifying v1beta1 still works, and this is just a backport from main so we shouldn't fix it here anyway...

kind: ServiceCIDR
metadata:
name: newcidr1
spec:
cidrs:
- 10.96.0.0/24

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.