Skip to content

Commit e368054

Browse files
Merge pull request #30821 from QiWang19/criocptests
OCPNODE-4031: Add criocredentialprovider tests
2 parents a209706 + 3052a44 commit e368054

108 files changed

Lines changed: 5277 additions & 636 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ require (
6161
github.com/opencontainers/go-digest v1.0.0
6262
github.com/openshift-eng/openshift-tests-extension v0.0.0-20251218142942-7ecc8801b9df
6363
github.com/openshift-kni/commatrix v0.0.5-0.20251111204857-e5a931eff73f
64-
github.com/openshift/api v0.0.0-20260114133223-6ab113cb7368
64+
github.com/openshift/api v0.0.0-20260225172252-64dddb8f3186
6565
github.com/openshift/apiserver-library-go v0.0.0-20251015164739-79d04067059d
6666
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
67-
github.com/openshift/client-go v0.0.0-20260108185524-48f4ccfc4e13
67+
github.com/openshift/client-go v0.0.0-20260219131751-7e63ce155298
6868
github.com/openshift/library-go v0.0.0-20251015151611-6fc7a74b67c5
6969
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20250118001652-a8b9c3c31417
7070
github.com/pborman/uuid v1.2.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,14 +844,14 @@ github.com/openshift-eng/openshift-tests-extension v0.0.0-20251218142942-7ecc880
844844
github.com/openshift-eng/openshift-tests-extension v0.0.0-20251218142942-7ecc8801b9df/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
845845
github.com/openshift-kni/commatrix v0.0.5-0.20251111204857-e5a931eff73f h1:E72Zoc+JImPehBrXkgaCbIDbSFuItvyX6RCaZ0FQE5k=
846846
github.com/openshift-kni/commatrix v0.0.5-0.20251111204857-e5a931eff73f/go.mod h1:cDVdp0eda7EHE6tLuSeo4IqPWdAX/KJK+ogBirIGtsI=
847-
github.com/openshift/api v0.0.0-20260114133223-6ab113cb7368 h1:kSr3DOlq0NCrHd65HB2o/pBsks7AfRm+fkpf9RLUPoc=
848-
github.com/openshift/api v0.0.0-20260114133223-6ab113cb7368/go.mod h1:d5uzF0YN2nQQFA0jIEWzzOZ+edmo6wzlGLvx5Fhz4uY=
847+
github.com/openshift/api v0.0.0-20260225172252-64dddb8f3186 h1:1IBqLfnTwrsauWPpvw4Wz7w57jAhHfUOHSGpKhXRNBg=
848+
github.com/openshift/api v0.0.0-20260225172252-64dddb8f3186/go.mod h1:ZYAxo9t1AALeEotN07tNzIvqqqWSxcZIqMUKnY/xCeQ=
849849
github.com/openshift/apiserver-library-go v0.0.0-20251015164739-79d04067059d h1:Mfya3RxHWvidOrKyHj3bmFn5x2B89DLZIvDAhwm+C2s=
850850
github.com/openshift/apiserver-library-go v0.0.0-20251015164739-79d04067059d/go.mod h1:zm2/rIUp0p83pz0/1kkSoKTqhTr3uUKSKQ9fP7Z3g7Y=
851851
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee h1:+Sp5GGnjHDhT/a/nQ1xdp43UscBMr7G5wxsYotyhzJ4=
852852
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE=
853-
github.com/openshift/client-go v0.0.0-20260108185524-48f4ccfc4e13 h1:6rd4zSo2UaWQcAPZfHK9yzKVqH0BnMv1hqMzqXZyTds=
854-
github.com/openshift/client-go v0.0.0-20260108185524-48f4ccfc4e13/go.mod h1:YvOmPmV7wcJxpfhTDuFqqs2Xpb3M3ovsM6Qs/i2ptq4=
853+
github.com/openshift/client-go v0.0.0-20260219131751-7e63ce155298 h1:V8uz/2Z4hh+49TUxl0nYs0sDn1fB7lTdSMDKAa6TFY8=
854+
github.com/openshift/client-go v0.0.0-20260219131751-7e63ce155298/go.mod h1:rtH0BhilT6+jn3nWybANEumaBO1vWCKaY8QpwipRy/Y=
855855
github.com/openshift/kubernetes v1.30.1-0.20251017123720-96593f323733 h1:Mpab1CmJPLVWGB0CNGoWnup/NScvv55MVPe94c8JgUk=
856856
github.com/openshift/kubernetes v1.30.1-0.20251017123720-96593f323733/go.mod h1:w3+IfrXNp5RosdDXg3LB55yijJqR/FwouvVntYHQf0o=
857857
github.com/openshift/kubernetes/staging/src/k8s.io/api v0.0.0-20251017123720-96593f323733 h1:42lm41QwjG8JoSicx4FHcuIG2kxHxlUnz6c+ftg2e0E=

test/extended/imagepolicy/imagepolicy.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ var _ = g.Describe("[sig-imagepolicy][OCPFeatureGate:SigstoreImageVerificationPK
198198

199199
func updateImageConfig(oc *exutil.CLI, allowedRegistries []string) {
200200
e2e.Logf("Updating image config with allowed registries")
201-
initialWorkerSpec := getMCPCurrentSpecConfigName(oc, workerPool)
202-
initialMasterSpec := getMCPCurrentSpecConfigName(oc, masterPool)
201+
initialWorkerSpec := GetMCPCurrentSpecConfigName(oc, workerPool)
202+
initialMasterSpec := GetMCPCurrentSpecConfigName(oc, masterPool)
203203

204204
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
205205
imageConfig, err := oc.AdminConfigClient().ConfigV1().Images().Get(
@@ -215,13 +215,13 @@ func updateImageConfig(oc *exutil.CLI, allowedRegistries []string) {
215215
return err
216216
})
217217
o.Expect(err).NotTo(o.HaveOccurred(), "error updating image config")
218-
waitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
219-
waitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
218+
WaitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
219+
WaitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
220220
}
221221

222222
func cleanupImageConfig(oc *exutil.CLI) error {
223-
initialWorkerSpec := getMCPCurrentSpecConfigName(oc, workerPool)
224-
initialMasterSpec := getMCPCurrentSpecConfigName(oc, masterPool)
223+
initialWorkerSpec := GetMCPCurrentSpecConfigName(oc, workerPool)
224+
initialMasterSpec := GetMCPCurrentSpecConfigName(oc, masterPool)
225225

226226
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
227227
imageConfig, err := oc.AdminConfigClient().ConfigV1().Images().Get(
@@ -237,8 +237,8 @@ func cleanupImageConfig(oc *exutil.CLI) error {
237237
return err
238238
})
239239
o.Expect(err).NotTo(o.HaveOccurred(), "error cleaning up image config")
240-
waitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
241-
waitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
240+
WaitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
241+
WaitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
242242
return nil
243243
}
244244

@@ -278,52 +278,52 @@ func waitForTestPodContainerToFailSignatureValidation(ctx context.Context, f *e2
278278

279279
func createClusterImagePolicy(oc *exutil.CLI, policy configv1.ClusterImagePolicy) {
280280
e2e.Logf("Creating cluster image policy %s", policy.Name)
281-
initialWorkerSpec := getMCPCurrentSpecConfigName(oc, workerPool)
282-
initialMasterSpec := getMCPCurrentSpecConfigName(oc, masterPool)
281+
initialWorkerSpec := GetMCPCurrentSpecConfigName(oc, workerPool)
282+
initialMasterSpec := GetMCPCurrentSpecConfigName(oc, masterPool)
283283

284284
_, err := oc.AdminConfigClient().ConfigV1().ClusterImagePolicies().Create(context.TODO(), &policy, metav1.CreateOptions{})
285285
o.Expect(err).NotTo(o.HaveOccurred())
286286

287-
waitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
288-
waitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
287+
WaitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
288+
WaitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
289289
}
290290

291291
func deleteClusterImagePolicy(oc *exutil.CLI, policyName string) error {
292-
initialWorkerSpec := getMCPCurrentSpecConfigName(oc, workerPool)
293-
initialMasterSpec := getMCPCurrentSpecConfigName(oc, masterPool)
292+
initialWorkerSpec := GetMCPCurrentSpecConfigName(oc, workerPool)
293+
initialMasterSpec := GetMCPCurrentSpecConfigName(oc, masterPool)
294294

295295
if err := oc.AdminConfigClient().ConfigV1().ClusterImagePolicies().Delete(context.TODO(), policyName, metav1.DeleteOptions{}); err != nil && !errors.IsNotFound(err) {
296296
return fmt.Errorf("failed to delete cluster image policy %s: %v", policyName, err)
297297
}
298-
waitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
299-
waitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
298+
WaitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
299+
WaitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
300300
return nil
301301
}
302302

303303
func createImagePolicy(oc *exutil.CLI, policy configv1.ImagePolicy, namespace string) {
304304
// Capture initial rendered config names for both pools before creating the policy
305-
initialWorkerSpec := getMCPCurrentSpecConfigName(oc, workerPool)
306-
initialMasterSpec := getMCPCurrentSpecConfigName(oc, masterPool)
305+
initialWorkerSpec := GetMCPCurrentSpecConfigName(oc, workerPool)
306+
initialMasterSpec := GetMCPCurrentSpecConfigName(oc, masterPool)
307307

308308
e2e.Logf("Creating image policy %s in namespace %s", policy.Name, namespace)
309309
_, err := oc.AdminConfigClient().ConfigV1().ImagePolicies(namespace).Create(context.TODO(), &policy, metav1.CreateOptions{})
310310
o.Expect(err).NotTo(o.HaveOccurred())
311311

312312
// Wait until each pool's Spec.Configuration.Name changes from the initial value
313313
// and the pool reports Updated=true
314-
waitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
315-
waitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
314+
WaitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
315+
WaitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
316316
}
317317

318318
func deleteImagePolicy(oc *exutil.CLI, policyName string, namespace string) error {
319-
initialWorkerSpec := getMCPCurrentSpecConfigName(oc, workerPool)
320-
initialMasterSpec := getMCPCurrentSpecConfigName(oc, masterPool)
319+
initialWorkerSpec := GetMCPCurrentSpecConfigName(oc, workerPool)
320+
initialMasterSpec := GetMCPCurrentSpecConfigName(oc, masterPool)
321321

322322
if err := oc.AdminConfigClient().ConfigV1().ImagePolicies(namespace).Delete(context.TODO(), policyName, metav1.DeleteOptions{}); err != nil && !errors.IsNotFound(err) {
323323
return fmt.Errorf("failed to delete image policy %s in namespace %s: %v", policyName, namespace, err)
324324
}
325-
waitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
326-
waitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
325+
WaitForMCPConfigSpecChangeAndUpdated(oc, workerPool, initialWorkerSpec)
326+
WaitForMCPConfigSpecChangeAndUpdated(oc, masterPool, initialMasterSpec)
327327
return nil
328328
}
329329

@@ -679,18 +679,18 @@ L8ITFP+Nw9Meiw4etw59CTAPCc7l4Zvwr1K2ZTBmVGxrqdasiqpI0utG69aItsPi
679679
return testImagePolicies
680680
}
681681

682-
// getMCPCurrentSpecConfigName returns the current Spec.Configuration.Name for the given MCP
683-
func getMCPCurrentSpecConfigName(oc *exutil.CLI, pool string) string {
682+
// GetMCPCurrentSpecConfigName returns the current Spec.Configuration.Name for the given MCP
683+
func GetMCPCurrentSpecConfigName(oc *exutil.CLI, pool string) string {
684684
clientSet, err := machineconfigclient.NewForConfig(oc.KubeFramework().ClientConfig())
685685
o.Expect(err).NotTo(o.HaveOccurred())
686686
mcp, err := clientSet.MachineconfigurationV1().MachineConfigPools().Get(context.TODO(), pool, metav1.GetOptions{})
687687
o.Expect(err).NotTo(o.HaveOccurred())
688688
return mcp.Spec.Configuration.Name
689689
}
690690

691-
// waitForMCPConfigSpecChangeAndUpdated waits until Spec.Configuration.Name changes from the provided initial value
691+
// WaitForMCPConfigSpecChangeAndUpdated waits until Spec.Configuration.Name changes from the provided initial value
692692
// and the MCP reports Updated=true
693-
func waitForMCPConfigSpecChangeAndUpdated(oc *exutil.CLI, pool string, initialSpecName string) {
693+
func WaitForMCPConfigSpecChangeAndUpdated(oc *exutil.CLI, pool string, initialSpecName string) {
694694
e2e.Logf("Waiting for pool %s to complete", pool)
695695
clientSet, err := machineconfigclient.NewForConfig(oc.KubeFramework().ClientConfig())
696696
o.Expect(err).NotTo(o.HaveOccurred())

0 commit comments

Comments
 (0)