Skip to content

Commit

Permalink
Add test to verify registry+v1 webhooks limitation
Browse files Browse the repository at this point in the history
No bundles with webhooks are currently allowed
and we must be clearly indicated in the conditions
of `ClusterExtension`

Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
  • Loading branch information
m1kola committed May 8, 2024
1 parent 6d73b73 commit 21d84b5
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test/e2e/cluster_extension_registryV1_limitations_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package e2e

import (
"context"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
)

func TestClusterExtensionPackagesWithWebhooksAreNotAllowed(t *testing.T) {
ctx := context.Background()
_, err := createTestCatalog(ctx, testCatalogName, os.Getenv(testCatalogRefEnvVar))
require.NoError(t, err)

deleteClusterExtension := func(clusterExtension *ocv1alpha1.ClusterExtension) {
require.NoError(t, c.Delete(ctx, clusterExtension))
require.Eventually(t, func() bool {
err := c.Get(ctx, types.NamespacedName{Name: clusterExtension.Name}, &ocv1alpha1.ClusterExtension{})
return errors.IsNotFound(err)
}, pollDuration, pollInterval)
}

// TODO: create test data and update this test (package name, version and assertions)
clusterExtension := &ocv1alpha1.ClusterExtension{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "package-with-webhooks-",
},
Spec: ocv1alpha1.ClusterExtensionSpec{
PackageName: "prometheus",
Version: "1.0.0",
InstallNamespace: "default",
},
}
require.NoError(t, c.Create(ctx, clusterExtension))
defer deleteClusterExtension(clusterExtension)

require.EventuallyWithT(t, func(ct *assert.CollectT) {
assert.NoError(ct, c.Get(ctx, types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))

cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
assert.NotNil(ct, cond)
assert.Equal(ct, metav1.ConditionFalse, cond.Status)
assert.Equal(ct, ocv1alpha1.ReasonInstallationFailed, cond.Reason)
assert.Contains(ct, cond.Message, "webhookDefinitions are not supported")
assert.Equal(ct, &ocv1alpha1.BundleMetadata{Name: "prometheus-operator.1.0.0", Version: "1.0.0"}, clusterExtension.Status.ResolvedBundle)
}, pollDuration, pollInterval)
}

0 comments on commit 21d84b5

Please sign in to comment.