-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Copy pathsubscription_content.go
93 lines (75 loc) · 3.73 KB
/
subscription_content.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package builds
import (
"path/filepath"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
admissionapi "k8s.io/pod-security-admission/api"
exutil "github.com/openshift/origin/test/extended/util"
)
var _ = g.Describe("[sig-builds][Feature:Builds][subscription-content] builds installing subscription content", func() {
defer g.GinkgoRecover()
var (
oc = exutil.NewCLIWithPodSecurityLevel("build-subscription-content", admissionapi.LevelBaseline)
baseDir = exutil.FixturePath("testdata", "builds", "subscription-content")
secretTemplate = filepath.Join(baseDir, "secret-template.txt")
imageStream = filepath.Join(baseDir, "build-imagestream.yaml")
rhel7BuildConfig = filepath.Join(baseDir, "buildconfig-subscription-content-rhel7.yaml")
rhel8BuildConfig = filepath.Join(baseDir, "buildconfig-subscription-content-rhel8.yaml")
rhel9BuildConfig = filepath.Join(baseDir, "buildconfig-subscription-content-rhel9.yaml")
)
g.Context("[apigroup:build.openshift.io]", func() {
g.BeforeEach(func() {
exutil.PreTestDump()
})
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.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()
})
})
})