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
1 change: 0 additions & 1 deletion test/e2e/catalogd/features/.gitkeep

This file was deleted.

2 changes: 2 additions & 0 deletions test/e2e/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/operator-framework/operator-controller/test/internal/e2e"
catalogsteps "github.com/operator-framework/operator-controller/test/internal/e2e/catalogd/steps"
objectsteps "github.com/operator-framework/operator-controller/test/internal/e2e/object-controller/steps"
operatorsteps "github.com/operator-framework/operator-controller/test/internal/e2e/operator-controller/steps"
platformsteps "github.com/operator-framework/operator-controller/test/internal/e2e/platform/steps"
"github.com/operator-framework/operator-controller/test/internal/e2e/steps"
Expand Down Expand Up @@ -45,6 +46,7 @@ func TestMain(m *testing.M) {
}, func(sc *godog.ScenarioContext) {
steps.RegisterSteps(sc)
catalogsteps.RegisterSteps(sc)
objectsteps.RegisterSteps(sc)
operatorsteps.RegisterSteps(sc)
platformsteps.RegisterDemoSteps(sc)
catalogsteps.RegisterHooks(sc)
Expand Down
1 change: 0 additions & 1 deletion test/e2e/object-controller/features/.gitkeep

This file was deleted.

2 changes: 2 additions & 0 deletions test/e2e/object-controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/cucumber/godog"

"github.com/operator-framework/operator-controller/test/internal/e2e"
objectsteps "github.com/operator-framework/operator-controller/test/internal/e2e/object-controller/steps"
operatorsteps "github.com/operator-framework/operator-controller/test/internal/e2e/operator-controller/steps"
"github.com/operator-framework/operator-controller/test/internal/e2e/steps"
)
Expand All @@ -16,6 +17,7 @@ func TestMain(m *testing.M) {
tc.BeforeSuite(steps.BeforeSuite)
}, func(sc *godog.ScenarioContext) {
steps.RegisterSteps(sc)
objectsteps.RegisterSteps(sc)
operatorsteps.RegisterSteps(sc)
steps.RegisterHooks(sc)
}))
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/operator-controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/cucumber/godog"

"github.com/operator-framework/operator-controller/test/internal/e2e"
objectsteps "github.com/operator-framework/operator-controller/test/internal/e2e/object-controller/steps"
operatorsteps "github.com/operator-framework/operator-controller/test/internal/e2e/operator-controller/steps"
"github.com/operator-framework/operator-controller/test/internal/e2e/steps"
)
Expand All @@ -16,6 +17,7 @@ func TestMain(m *testing.M) {
tc.BeforeSuite(steps.BeforeSuite)
}, func(sc *godog.ScenarioContext) {
steps.RegisterSteps(sc)
objectsteps.RegisterSteps(sc)
operatorsteps.RegisterSteps(sc)
steps.RegisterHooks(sc)
}))
Expand Down
1 change: 0 additions & 1 deletion test/e2e/platform/features/.gitkeep

This file was deleted.

794 changes: 794 additions & 0 deletions test/internal/e2e/object-controller/steps/steps.go

Large diffs are not rendered by default.

109 changes: 0 additions & 109 deletions test/internal/e2e/steps/group_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (

"github.com/cucumber/godog"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -96,110 +94,3 @@ func ListClusterObjectSetsInGroup(ctx context.Context, group string) ([]ocv1.Clu
}
return list.Items, nil
}

func ClusterObjectSetHasGroup(ctx context.Context, revisionName, group string) error {
sc := Scenario(ctx)
revisionName = SubstituteScenarioVars(revisionName, sc)
group = SubstituteScenarioVars(group, sc)
WaitFor(ctx, func() bool {
obj, err := GetResource("clusterobjectset", revisionName, "")
if err != nil {
return false
}
var cos ocv1.ClusterObjectSet
return runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &cos) == nil && cos.Spec.Group == group
})
return nil
}

// ClusterObjectSetObjectsUseSSAManager checks actual managed fields on every
// inline or externally stored phase object, including their revision owner.
func ClusterObjectSetObjectsUseSSAManager(ctx context.Context, revisionName, manager string) error {
sc := Scenario(ctx)
revisionName = SubstituteScenarioVars(revisionName, sc)
manager = SubstituteScenarioVars(manager, sc)
WaitFor(ctx, func() bool {
obj, err := GetResource("clusterobjectset", revisionName, "")
if err != nil {
return false
}
var cos ocv1.ClusterObjectSet
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &cos); err != nil {
return false
}
count := 0
for _, phase := range cos.Spec.Phases {
for _, phaseObj := range phase.Objects {
desired := &phaseObj.InlineManifest
if phaseObj.Type == ocv1.ObjectTypeSecretReference {
desired, err = ResolveSecretRef(phaseObj.SecretRef)
if err != nil {
return false
}
}
// kubectl's JSON/YAML printers omit managedFields by default.
args := []string{"get", desired.GetKind(), desired.GetName(), "-o", "json", "--show-managed-fields"}
if desired.GetNamespace() != "" {
args = append(args, "-n", desired.GetNamespace())
}
out, err := K8sClient(ctx, args...)
if err != nil {
return false
}
actual := &unstructured.Unstructured{}
if err := json.Unmarshal([]byte(out), &actual.Object); err != nil {
return false
}
owner := metav1.GetControllerOf(actual)
if owner == nil || owner.Kind != ocv1.ClusterObjectSetKind || owner.UID != cos.UID {
return false
}
found := false
for _, fields := range actual.GetManagedFields() {
if fields.Operation != metav1.ManagedFieldsOperationApply {
continue
}
if strings.HasPrefix(fields.Manager, "cos-group/") && fields.Manager != manager {
return false
}
if fields.Manager == manager {
found = true
}
}
if !found {
return false
}
count++
}
}
return count > 0
})
return nil
}

func RememberClusterObjectSetSecrets(ctx context.Context, revisionName string) error {
sc := Scenario(ctx)
revisionName = SubstituteScenarioVars(revisionName, sc)
names, err := CollectReferredSecretNames(ctx, revisionName)
if err != nil {
return err
}
for _, name := range names {
sc.RevisionSecrets = append(sc.RevisionSecrets, Resource{Kind: "secret", Name: name, Namespace: OLMNamespace})
}
return nil
}

func RememberedRevisionSecretsRemoved(ctx context.Context) error {
sc := Scenario(ctx)
if len(sc.RevisionSecrets) == 0 {
return fmt.Errorf("no revision secrets were remembered")
}
for _, secret := range sc.RevisionSecrets {
WaitFor(ctx, func() bool {
out, err := K8sClient(ctx, "get", secret.Kind, secret.Name, "-n", secret.Namespace, "--ignore-not-found", "-o", "name")
return err == nil && strings.TrimSpace(out) == ""
})
}
return nil
}
Loading
Loading