Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUDP-284179: test/e2e/atlas: filter global kinds for certain e2e tests #3404

Merged
merged 1 commit into from
Nov 22, 2024
Merged
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
21 changes: 21 additions & 0 deletions test/e2e/atlas/kubernetes_config_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ const targetNamespace = "importer-namespace"
const credSuffixTest = "-credentials"
const activeStatus = "ACTIVE"

// These kinds represent global types in AKO which are independent of any Atlas Project.
// They can be filtered in concurrent e2e tests if they are not relevant for assertion.
var globalKinds = []string{"AtlasFederatedAuth"}

var federationSettingsID string
var identityProviderStatus string
var samlIdentityProviderID string
Expand Down Expand Up @@ -209,13 +213,30 @@ func TestExportIndependentOrNot(t *testing.T) {
require.NoError(t, err, string(resp))
var objects []runtime.Object
objects, err = getK8SEntities(resp)
// We want to filter spurious federated auth resources from other tests
// as these are global resources across all projects.
objects = filtered(objects).byKind(globalKinds...)
require.NoError(t, err, "should not fail on decode but got:\n"+string(resp))
require.NotEmpty(t, objects)
require.Equal(t, tc.expected, objects)
})
}
}

type filtered []runtime.Object

func (f filtered) byKind(kinds ...string) []runtime.Object {
result := f[:0]
for _, obj := range f {
for _, kind := range kinds {
if obj.GetObjectKind().GroupVersionKind().Kind != kind {
result = append(result, obj)
}
}
}
return result
}

func defaultTestProject(name, namespace string, labels map[string]string, alertConfigs bool) *akov2.AtlasProject {
project := &akov2.AtlasProject{
TypeMeta: metav1.TypeMeta{
Expand Down