-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to verify registry+v1 webhooks limitation
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
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |