Skip to content

Commit

Permalink
update integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: ashish <asnaraya@redhat.com>
  • Loading branch information
ashishmax31 committed Jun 20, 2022
1 parent 148968a commit 0ae3965
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
15 changes: 8 additions & 7 deletions integration/addon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

addonsv1alpha1 "github.com/openshift/addon-operator/apis/addons/v1alpha1"
"github.com/openshift/addon-operator/integration"
addonUtil "github.com/openshift/addon-operator/internal/controllers/addon"
)

func (s *integrationTestSuite) TestAddon() {
Expand Down Expand Up @@ -119,7 +120,7 @@ func (s *integrationTestSuite) TestAddon() {
s.Run("catalogsource exists", func() {
currentCatalogSource := &operatorsv1alpha1.CatalogSource{}
err := integration.Client.Get(ctx, client.ObjectKey{
Name: addon.Name,
Name: addonUtil.CatalogSourceName(addon),
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
}, currentCatalogSource)
s.Assert().NoError(err, "could not get CatalogSource %s", addon.Name)
Expand All @@ -133,7 +134,7 @@ func (s *integrationTestSuite) TestAddon() {
{
err := integration.Client.Get(ctx, client.ObjectKey{
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
Name: addon.Name,
Name: addonUtil.SubscriptionName(addon),
}, subscription)
s.Require().NoError(err)

Expand Down Expand Up @@ -164,7 +165,7 @@ func (s *integrationTestSuite) TestAddon() {

err := integration.Client.Get(ctx, client.ObjectKey{
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
Name: addon.Name,
Name: addonUtil.SubscriptionName(addon),
}, subscription)
s.Require().NoError(err)
envObjectsPresent := subscription.Spec.Config.Env
Expand All @@ -187,7 +188,7 @@ func (s *integrationTestSuite) TestAddon() {
// assert that CatalogSource is gone
currentCatalogSource := &operatorsv1alpha1.CatalogSource{}
err = integration.Client.Get(ctx, client.ObjectKey{
Name: addon.Name,
Name: addonUtil.CatalogSourceName(addon),
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
}, currentCatalogSource)
s.Assert().True(k8sApiErrors.IsNotFound(err), "CatalogSource not deleted: %s", currentCatalogSource.Name)
Expand Down Expand Up @@ -232,9 +233,9 @@ func (s *integrationTestSuite) TestAddonWithAdditionalCatalogSrc() {
s.Assert().NoError(err, "could not get CatalogSource %s", addon.Name)
s.Assert().Equal(3, len(catalogSourceList.Items))
expectedImages := map[string]string{
"test-1": referenceAddonCatalogSourceImageWorking,
"test-2": referenceAddonCatalogSourceImageWorking,
addon.Name: referenceAddonCatalogSourceImageWorking,
"test-1": referenceAddonCatalogSourceImageWorking,
"test-2": referenceAddonCatalogSourceImageWorking,
addonUtil.CatalogSourceName(addon): referenceAddonCatalogSourceImageWorking,
}
for _, ctlgSrc := range catalogSourceList.Items {
s.Assert().Equal(expectedImages[ctlgSrc.Name], ctlgSrc.Spec.Image)
Expand Down
5 changes: 3 additions & 2 deletions integration/broken_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

addonsv1alpha1 "github.com/openshift/addon-operator/apis/addons/v1alpha1"
"github.com/openshift/addon-operator/integration"
addonUtil "github.com/openshift/addon-operator/internal/controllers/addon"
)

// This test deploys a version of our addon where InstallPlan and
Expand Down Expand Up @@ -55,7 +56,7 @@ func (s *integrationTestSuite) TestAddon_BrokenSubscription() {
subscription := &operatorsv1alpha1.Subscription{}
err := integration.Client.Get(ctx, client.ObjectKey{
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
Name: addon.Name,
Name: addonUtil.SubscriptionName(addon),
}, subscription)
s.Require().NoError(err)

Expand All @@ -73,7 +74,7 @@ func (s *integrationTestSuite) TestAddon_BrokenSubscription() {
// assert that CatalogSource is gone
currentCatalogSource := &operatorsv1alpha1.CatalogSource{}
err = integration.Client.Get(ctx, types.NamespacedName{
Name: addon.Name,
Name: addonUtil.CatalogSourceName(addon),
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
}, currentCatalogSource)
s.Assert().True(k8sApiErrors.IsNotFound(err), "CatalogSource not deleted: %s", currentCatalogSource.Name)
Expand Down
4 changes: 2 additions & 2 deletions integration/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func namespace_TestResourceAdoption() *corev1.Namespace {
func catalogsource_TestResourceAdoption() *operatorsv1alpha1.CatalogSource {
return &operatorsv1alpha1.CatalogSource{
ObjectMeta: metav1.ObjectMeta{
Name: referenceAddonName,
Name: fmt.Sprintf("addon-%s-catalog", referenceAddonName),
Namespace: referenceAddonNamespace,
},
Spec: operatorsv1alpha1.CatalogSourceSpec{
Expand All @@ -247,7 +247,7 @@ func operatorgroup_TestResourceAdoption() *operatorsv1.OperatorGroup {
func subscription_TestResourceAdoption() *operatorsv1alpha1.Subscription {
return &operatorsv1alpha1.Subscription{
ObjectMeta: metav1.ObjectMeta{
Name: referenceAddonName,
Name: fmt.Sprintf("addon-%s", referenceAddonName),
Namespace: referenceAddonNamespace},
Spec: &operatorsv1alpha1.SubscriptionSpec{
CatalogSource: referenceAddonName,
Expand Down
5 changes: 3 additions & 2 deletions integration/resource_adoption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
addonsv1alpha1 "github.com/openshift/addon-operator/apis/addons/v1alpha1"
"github.com/openshift/addon-operator/integration"
"github.com/openshift/addon-operator/internal/controllers"
addonUtil "github.com/openshift/addon-operator/internal/controllers/addon"
)

func (s *integrationTestSuite) TestResourceAdoption() {
Expand Down Expand Up @@ -107,7 +108,7 @@ func (s *integrationTestSuite) TestResourceAdoption() {
{
observedSubscription := &operatorsv1alpha1.Subscription{
ObjectMeta: metav1.ObjectMeta{
Name: referenceAddonName,
Name: addonUtil.SubscriptionName(addon),
Namespace: referenceAddonNamespace,
},
}
Expand Down Expand Up @@ -142,7 +143,7 @@ func (s *integrationTestSuite) TestResourceAdoption() {
{
observedCS := &operatorsv1alpha1.CatalogSource{
ObjectMeta: metav1.ObjectMeta{
Name: referenceAddonName,
Name: addonUtil.CatalogSourceName(addon),
Namespace: referenceAddonNamespace,
},
}
Expand Down

0 comments on commit 0ae3965

Please sign in to comment.