Skip to content

Commit

Permalink
restore context
Browse files Browse the repository at this point in the history
  • Loading branch information
adambkaplan committed Jan 27, 2024
1 parent 23276dc commit e288bf6
Showing 1 changed file with 57 additions and 52 deletions.
109 changes: 57 additions & 52 deletions test/extended/builds/subscription_content.go
Expand Up @@ -27,62 +27,67 @@ var _ = g.Describe("[sig-builds][Feature:Builds][subscription-content] builds in
rhel9BuildConfig = filepath.Join(baseDir, "buildconfig-subscription-content-rhel9.yaml")
)

g.BeforeEach(func() {
exutil.PreTestDump()
})
g.Context("[apigroup:build.openshift.io]", func() {

g.JustBeforeEach(func(ctx g.SpecContext) {
g.By("copying entitlement keys to namespace")
// The Insights Operator is responsible for retrieving the entitlement keys for the
// cluster and syncing them to the openshift-config-managed namespace.
// If this secret is not present, it means the cluster is not a Red Hat subscribed
// cluster and is not eligible to include entitled RHEL content in builds.
_, err := oc.AdminKubeClient().CoreV1().Secrets("openshift-config-managed").Get(ctx, "etc-pki-entitlement", metav1.GetOptions{})
if kerrors.IsNotFound(err) {
g.Skip("cluster entitlements not found")
}
// We should not expect an error other than "not found"
o.Expect(err).NotTo(o.HaveOccurred(), "getting secret openshift-config-managed/etc-pki-entitlement")
// Without the shared resoruces CSI driver, we must manually copy the entitlement keys
// to the build namespace.

// Run oc commands as per the openshift documentation
stdOut, _, err := oc.AsAdmin().Run("get").Args("secret", "etc-pki-entitlement", "-n", "openshift-config-managed", "-o=go-template-file", "--template", secretTemplate).Outputs()
o.Expect(err).NotTo(o.HaveOccurred(), "getting secret openshift-config-managed/etc-pki-entitlement")
err = oc.Run("apply").Args("-f", "-").InputString(stdOut).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating secret etc-pki-entitlement")

g.By("setting up build outputs")
err = oc.Run("apply").Args("-f", imageStream).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating build output imagestream")
})
g.BeforeEach(func() {
exutil.PreTestDump()
})

g.AfterEach(func() {
if g.CurrentSpecReport().Failed() {
exutil.DumpPodStates(oc)
exutil.DumpConfigMapStates(oc)
exutil.DumpPodLogsStartingWith("", oc)
}
})
g.JustBeforeEach(func(ctx g.SpecContext) {
g.By("copying entitlement keys to namespace")
// The Insights Operator is responsible for retrieving the entitlement keys for the
// cluster and syncing them to the openshift-config-managed namespace.
// If this secret is not present, it means the cluster is not a Red Hat subscribed
// cluster and is not eligible to include entitled RHEL content in builds.
_, err := oc.AdminKubeClient().CoreV1().Secrets("openshift-config-managed").Get(ctx, "etc-pki-entitlement", metav1.GetOptions{})
if kerrors.IsNotFound(err) {
g.Skip("cluster entitlements not found")
}
// We should not expect an error other than "not found"
o.Expect(err).NotTo(o.HaveOccurred(), "getting secret openshift-config-managed/etc-pki-entitlement")
// Without the shared resoruces CSI driver, we must manually copy the entitlement keys
// to the build namespace.

g.It("should succeed for RHEL 7 base images", func() {
err := oc.Run("apply").Args("-f", rhel7BuildConfig).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating BuildConfig")
br, _ := exutil.StartBuildAndWait(oc, "subscription-content-rhel7")
br.AssertSuccess()
})
// Run oc commands as per the openshift documentation
stdOut, _, err := oc.AsAdmin().Run("get").Args("secret", "etc-pki-entitlement", "-n", "openshift-config-managed", "-o=go-template-file", "--template", secretTemplate).Outputs()
o.Expect(err).NotTo(o.HaveOccurred(), "getting secret openshift-config-managed/etc-pki-entitlement")
err = oc.Run("apply").Args("-f", "-").InputString(stdOut).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating secret etc-pki-entitlement")

g.It("should succeed for RHEL 8 base images", func() {
err := oc.Run("apply").Args("-f", rhel8BuildConfig).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating BuildConfig")
br, _ := exutil.StartBuildAndWait(oc, "subscription-content-rhel8")
br.AssertSuccess()
})
g.By("setting up build outputs")
err = oc.Run("apply").Args("-f", imageStream).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating build output imagestream")
})

g.AfterEach(func() {
if g.CurrentSpecReport().Failed() {
exutil.DumpPodStates(oc)
exutil.DumpConfigMapStates(oc)
exutil.DumpPodLogsStartingWith("", oc)
}
})

g.It("should succeed for RHEL 7 base images", func() {
err := oc.Run("apply").Args("-f", rhel7BuildConfig).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating BuildConfig")
br, _ := exutil.StartBuildAndWait(oc, "subscription-content-rhel7")
br.AssertSuccess()
})

g.It("should succeed for RHEL 8 base images", func() {
err := oc.Run("apply").Args("-f", rhel8BuildConfig).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating BuildConfig")
br, _ := exutil.StartBuildAndWait(oc, "subscription-content-rhel8")
br.AssertSuccess()
})

g.It("should succeed for RHEL 9 base images", func() {
err := oc.Run("apply").Args("-f", rhel9BuildConfig).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating BuildConfig")
br, _ := exutil.StartBuildAndWait(oc, "subscription-content-rhel9")
br.AssertSuccess()
})

g.It("should succeed for RHEL 9 base images", func() {
err := oc.Run("apply").Args("-f", rhel9BuildConfig).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "creating BuildConfig")
br, _ := exutil.StartBuildAndWait(oc, "subscription-content-rhel9")
br.AssertSuccess()
})

})

0 comments on commit e288bf6

Please sign in to comment.