Skip to content

Commit 120a530

Browse files
alecmerdlernjhale
authored andcommitted
fix(e2e): create CSV first to use in CRD ownerref
1 parent b384006 commit 120a530

File tree

2 files changed

+21
-37
lines changed

2 files changed

+21
-37
lines changed

cmd/olm/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
"interval", defaultWakeupInterval, "wake up interval")
3535

3636
watchedNamespaces = flag.String(
37-
"watchedNamespaces", "", "comma separated list of namespaces for alm operator to watch. "+
37+
"watchedNamespaces", "", "comma separated list of namespaces for olm operator to watch. "+
3838
"If not set, or set to the empty string (e.g. `-watchedNamespaces=\"\"`), "+
3939
"olm operator will watch all namespaces in the cluster.")
4040

@@ -48,7 +48,7 @@ func init() {
4848
metrics.Register()
4949
}
5050

51-
// main function - entrypoint to ALM operator
51+
// main function - entrypoint to OLM operator
5252
func main() {
5353
stopCh := signals.SetupSignalHandler()
5454

test/e2e/csv_e2e_test.go

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,16 @@ func TestCreateCSVRequirementsMetCRD(t *testing.T) {
596596
},
597597
}
598598

599-
// Create dependency first (CRD)
599+
// Create CSV first, knowing it will fail
600+
cleanupCSV, err := createCSV(t, c, crc, csv, testNamespace, true, false)
601+
require.NoError(t, err)
602+
defer cleanupCSV()
603+
604+
fetchedCSV, err := fetchCSV(t, crc, csv.Name, csvPendingChecker)
605+
require.NoError(t, err)
606+
600607
crd := extv1beta1.CustomResourceDefinition{
601-
ObjectMeta: metav1.ObjectMeta{
602-
Name: crdName,
603-
},
608+
ObjectMeta: metav1.ObjectMeta{Name: crdName},
604609
Spec: extv1beta1.CustomResourceDefinitionSpec{
605610
Group: "cluster.com",
606611
Version: "v1alpha1",
@@ -613,6 +618,12 @@ func TestCreateCSVRequirementsMetCRD(t *testing.T) {
613618
Scope: "Namespaced",
614619
},
615620
}
621+
crd.SetOwnerReferences([]metav1.OwnerReference{{
622+
Name: fetchedCSV.GetName(),
623+
APIVersion: v1alpha1.ClusterServiceVersionAPIVersion,
624+
Kind: v1alpha1.ClusterServiceVersionKind,
625+
UID: fetchedCSV.GetUID(),
626+
}})
616627
cleanupCRD, err := createCRD(c, crd)
617628
require.NoError(t, err)
618629

@@ -714,39 +725,12 @@ func TestCreateCSVRequirementsMetCRD(t *testing.T) {
714725
_, err = c.CreateClusterRoleBinding(&nonResourceClusterRoleBinding)
715726
require.NoError(t, err, "could not create ClusterRoleBinding")
716727

717-
cleanupCSV, err := createCSV(t, c, crc, csv, testNamespace, true, false)
718-
require.NoError(t, err)
719-
defer cleanupCSV()
720-
721-
fmt.Println("checking for deployment")
722-
// Poll for deployment to be ready
723-
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
724-
dep, err := c.GetDeployment(testNamespace, depName)
725-
if k8serrors.IsNotFound(err) {
726-
fmt.Printf("deployment %s not found\n", depName)
727-
return false, nil
728-
} else if err != nil {
729-
fmt.Printf("unexpected error fetching deployment %s\n", depName)
730-
return false, err
731-
}
732-
if dep.Status.UpdatedReplicas == *(dep.Spec.Replicas) &&
733-
dep.Status.Replicas == *(dep.Spec.Replicas) &&
734-
dep.Status.AvailableReplicas == *(dep.Spec.Replicas) {
735-
fmt.Println("deployment ready")
736-
return true, nil
737-
}
738-
fmt.Println("deployment not ready")
739-
return false, nil
740-
})
741-
require.NoError(t, err)
742-
743-
fetchedCSV, err := fetchCSV(t, crc, csv.Name, csvSucceededChecker)
728+
// Wait for CSV success
729+
_, err = fetchCSV(t, crc, csv.Name, csvSucceededChecker)
744730
require.NoError(t, err)
745731

746-
// Fetch cluster service version again to check for unnecessary control loops
747-
sameCSV, err := fetchCSV(t, crc, csv.Name, csvSucceededChecker)
732+
fetchedCSV, err = fetchCSV(t, crc, csv.Name, csvSucceededChecker)
748733
require.NoError(t, err)
749-
compareResources(t, fetchedCSV, sameCSV)
750734

751735
// Delete CRD
752736
cleanupCRD()
@@ -760,7 +744,7 @@ func TestCreateCSVRequirementsMetCRD(t *testing.T) {
760744
require.NoError(t, err)
761745
defer cleanupCRD()
762746

763-
// Wait for CSV success
747+
// Wait for CSV success again
764748
fetchedCSV, err = fetchCSV(t, crc, csv.Name, csvSucceededChecker)
765749
require.NoError(t, err)
766750
}

0 commit comments

Comments
 (0)