Skip to content

Commit

Permalink
UPSTREAM: <carry>: refactor/improve CRD publishing e2e tests in an HA…
Browse files Browse the repository at this point in the history
… setup

UPSTREAM: <carry>: refactor/improve CRD publishing e2e tests in an HA setup

OpenShift-Rebase-Source: 51aeef3
OpenShift-Rebase-Source: 7fbb6a4
  • Loading branch information
p0lyn0mial authored and soltysh committed Dec 8, 2023
1 parent af64381 commit 33563ca
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions test/e2e/apimachinery/crd_publish_openapi.go
Expand Up @@ -521,7 +521,13 @@ func setupCRDAndVerifySchema(f *framework.Framework, schema, expect []byte, grou
return setupCRDAndVerifySchemaWithOptions(f, schema, expect, groupSuffix, versions)
}

func setupCRDAndVerifySchemaWithOptions(f *framework.Framework, schema, expect []byte, groupSuffix string, versions []string, options ...crd.Option) (*crd.TestCrd, error) {
func setupCRDAndVerifySchemaWithOptions(f *framework.Framework, schema, expect []byte, groupSuffix string, versions []string, options ...crd.Option) (tCRD *crd.TestCrd, err error) {
defer func() {
if err != nil {
framework.Logf("sleeping 45 seconds before running the actual tests, we hope that during all API servers converge during that window, see %q for more", "https://github.com/kubernetes/kubernetes/pull/90452")
time.Sleep(time.Second * 45)
}
}()
group := fmt.Sprintf("%s-test-%s.example.com", f.BaseName, groupSuffix)
if len(versions) == 0 {
return nil, fmt.Errorf("require at least one version for CRD")
Expand Down Expand Up @@ -559,17 +565,17 @@ func setupCRDAndVerifySchemaWithOptions(f *framework.Framework, schema, expect [
}
crd.Spec.Versions = apiVersions
})
crd, err := crd.CreateMultiVersionTestCRD(f, group, options...)
tCRD, err = crd.CreateMultiVersionTestCRD(f, group, options...)
if err != nil {
return nil, fmt.Errorf("failed to create CRD: %w", err)
}

for _, v := range crd.Crd.Spec.Versions {
if err := waitForDefinition(f.ClientSet, definitionName(crd, v.Name), expect); err != nil {
for _, v := range tCRD.Crd.Spec.Versions {
if err := waitForDefinition(f.ClientSet, definitionName(tCRD, v.Name), expect); err != nil {
return nil, fmt.Errorf("%v", err)
}
}
return crd, nil
return tCRD, nil
}

func cleanupCRD(ctx context.Context, f *framework.Framework, crd *crd.TestCrd) error {
Expand Down

0 comments on commit 33563ca

Please sign in to comment.