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

Added new talm batching test #59

Merged
merged 1 commit into from
Feb 1, 2024
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
30 changes: 30 additions & 0 deletions tests/ranfunc/talm/internal/talmhelper/talmhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1062,3 +1062,33 @@ func EnableCgu(client *clients.Settings, cgu *cgu.CguBuilder) error {

return err
}

// WaitForCguToTimeout waits until the provided CGU reaches to a succeeded state or a timeout.
func WaitForCguToTimeout(cguName string, namespace string, timeout time.Duration) error {
// Wait for the cgu to timeout
glog.V(100).Info("waiting for CGU to timeout")

// TALM uses different conditions starting in 4.12
conditionType := SucceededType
conditionReason := "TimedOut"

if !ranfunchelper.IsVersionStringInRange(
TalmHubVersion,
talmparams.TalmUpdatedConditionsVersion,
"",
) {
conditionType = ReadyType
conditionReason = "UpgradeTimedOut"
}

return WaitForCguInCondition(
ranfuncinittools.HubAPIClient,
cguName,
namespace,
conditionType,
"",
"",
conditionReason,
timeout,
)
}
100 changes: 100 additions & 0 deletions tests/ranfunc/talm/tests/talm_batching.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/openshift-kni/eco-goinfra/pkg/cgu"
"github.com/openshift-kni/eco-goinfra/pkg/clients"
"github.com/openshift-kni/eco-goinfra/pkg/namespace"
"github.com/openshift-kni/eco-goinfra/pkg/olm"
"github.com/openshift-kni/eco-gosystem/tests/internal/cluster"
"github.com/openshift-kni/eco-gosystem/tests/ranfunc/internal/ranfunchelper"
"github.com/openshift-kni/eco-gosystem/tests/ranfunc/internal/ranfuncinittools"
"github.com/openshift-kni/eco-gosystem/tests/ranfunc/talm/internal/talmhelper"
"github.com/openshift-kni/eco-gosystem/tests/ranfunc/talm/internal/talmparams"
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
configurationPolicyv1 "open-cluster-management.io/config-policy-controller/api/v1"
)

var _ = Describe("Talm Batching Tests", Ordered, Label("talmbatching"), func() {
Expand Down Expand Up @@ -149,5 +154,100 @@ var _ = Describe("Talm Batching Tests", Ordered, Label("talmbatching"), func() {
Expect(err).ToNot(HaveOccurred())
})
})

// 47952
It("should report the failed spoke when one spoke in a batch times out", func() {
namespaceBuilder := namespace.NewBuilder(ranfuncinittools.SpokeAPIClient, talmhelper.TemporaryNamespaceName)

By("creating the temporary namespace on spoke1 only", func() {
_, err := namespaceBuilder.Create()
Expect(err).ToNot(HaveOccurred())
})
By("verifying the temporary namespace exists on spoke1", func() {
result := namespaceBuilder.Exists()
Expect(result).To(BeTrue())
})
By("verifying the temporary namespace does not exist on spoke2", func() {
nsExist := namespace.NewBuilder(talmhelper.Spoke2APIClient, talmhelper.TemporaryNamespaceName).Exists()
Expect(nsExist).To(BeFalse())
})
By("creating the cgu and associated resources", func() {
// This test uses a max concurrency of 2
// This way both spokes are in the same batch
clusterGroupUpgrade := talmhelper.GetCguDefinition(
talmhelper.CguName,
[]string{
talmhelper.Spoke1Name,
talmhelper.Spoke2Name,
},
[]string{},
[]string{
talmhelper.PolicyName,
},
talmhelper.Namespace,
2,
9,
)
clusterGroupUpgrade.Definition.Spec.Enable = talmhelper.BoolAddr(false)

catsrc := talmhelper.GetCatsrcDefinition(
talmhelper.CatalogSourceName,
talmhelper.TemporaryNamespaceName,
operatorsv1alpha1.SourceTypeInternal,
1,
"",
"",
"",
talmhelper.CatalogSourceName,
)

err := talmhelper.CreatePolicyAndCgu(
ranfuncinittools.HubAPIClient,
catsrc.Definition,
configurationPolicyv1.MustHave,
configurationPolicyv1.Inform,
talmhelper.PolicyName,
talmhelper.PolicySetName,
talmhelper.PlacementBindingName,
talmhelper.PlacementRule,
talmhelper.Namespace,
metav1.LabelSelector{},
clusterGroupUpgrade,
)
Expect(err).ToNot(HaveOccurred())

By("waiting for the system to settle", func() {
time.Sleep(talmparams.TalmSystemStablizationTime)
})

By("enabling the CGU", func() {
clusterGroupUpgrade, err := cgu.Pull(ranfuncinittools.HubAPIClient, talmhelper.CguName, talmhelper.Namespace)
Expect(err).ToNot(HaveOccurred())

err = talmhelper.EnableCgu(ranfuncinittools.HubAPIClient, clusterGroupUpgrade)
Expect(err).ToNot(HaveOccurred())
})

By("waiting for the cgu to timeout", func() {
err := talmhelper.WaitForCguToTimeout(talmhelper.CguName, talmhelper.Namespace, 16*time.Minute)
Expect(err).ToNot(HaveOccurred())
})

By("validating that the policy was successful on spoke2", func() {
catSrcExists := olm.NewCatalogSourceBuilder(talmhelper.Spoke2APIClient,
talmhelper.CatalogSourceName, talmhelper.TemporaryNamespaceName).Exists()
Expect(catSrcExists).To(BeTrue())
})

By("validating that the policy was not successful on spoke1", func() {
catSrcExists := olm.NewCatalogSourceBuilder(ranfuncinittools.SpokeAPIClient,
talmhelper.CatalogSourceName, talmhelper.TemporaryNamespaceName).Exists()
err = talmhelper.FilterMissingResourceErrors(err)
Expect(err).ToNot(HaveOccurred())
Expect(catSrcExists).To(BeFalse())
})
})
})

})
})
Loading