@@ -56,7 +56,7 @@ func NewTestClient() *TestClient {
5656}
5757
5858// GetPodByLabel is a function that takes label and namespace and returns the pod and error
59- func (tc * TestClient ) GetPodByLabel (label string , namespace string ) (* corev1.Pod , error ) {
59+ func (tc * TestClient ) GetPodByLabel (label string , namespace string ) (* corev1.PodList , error ) {
6060
6161 pods , err := tc .K8sClient .CoreV1 ().Pods (namespace ).List (metav1.ListOptions {LabelSelector : label })
6262 if err != nil {
@@ -65,7 +65,7 @@ func (tc *TestClient) GetPodByLabel(label string, namespace string) (*corev1.Pod
6565 if len (pods .Items ) == 0 {
6666 return nil , nil
6767 }
68- return & pods . Items [ 0 ] , nil
68+ return pods , nil
6969}
7070
7171//GetSubscription returns subscription struct
@@ -92,45 +92,25 @@ func (tc *TestClient) GetInstallPlan(installPlanName, namespace string) (*apis_v
9292func (tc * TestClient ) Delete (resource , name , namespace string ) error {
9393 switch resource {
9494 case "subscription" , "sub" :
95- err := tc .OperatorClient .Subscriptions (namespace ).Delete (name , & metav1.DeleteOptions {})
96- if err != nil {
97- return err
98- }
99- return nil
95+ return tc .OperatorClient .Subscriptions (namespace ).Delete (name , & metav1.DeleteOptions {})
10096 case "installplan" :
101- err := tc .OperatorClient .InstallPlans (namespace ).Delete (name , & metav1.DeleteOptions {})
102- if err != nil {
103- return err
104- }
105- return nil
106- case "catalogsource" , "catsrc" :
107- err := tc .OperatorClient .CatalogSources (namespace ).Delete (name , & metav1.DeleteOptions {})
108- if err != nil {
109- return err
110- }
111- return nil
97+ return tc .OperatorClient .InstallPlans (namespace ).Delete (name , & metav1.DeleteOptions {})
98+ case "catalogsource" , "catsrc" , "csc" :
99+ return tc .OperatorClient .CatalogSources (namespace ).Delete (name , & metav1.DeleteOptions {})
112100 case "clusterserviceversion" , "csv" :
113- err := tc .OperatorClient .ClusterServiceVersions (namespace ).Delete (name , & metav1.DeleteOptions {})
114- if err != nil {
115- return err
116- }
117- return nil
101+ return tc .OperatorClient .ClusterServiceVersions (namespace ).Delete (name , & metav1.DeleteOptions {})
118102 case "pod" :
119- err := tc .K8sClient .CoreV1 ().Pods (namespace ).Delete (name , & metav1.DeleteOptions {})
120- if err != nil {
121- return err
122- }
123- return nil
103+ return tc .K8sClient .CoreV1 ().Pods (namespace ).Delete (name , & metav1.DeleteOptions {})
124104 default :
125105 option := fmt .Sprintf ("Invalid resource: %s" , resource )
126106 return errors .New (option )
127107
128108 }
129109}
130110
131- //WaitForOperatorDeployment takes pod struct and wait till pods gets in runnig state
111+ //WaitForOperatorDeployment takes pod name and wait till pod gets in runnig state
132112func (tc * TestClient ) WaitForOperatorDeployment (t * testing.T , name , namespace string , retryInterval , timeout time.Duration ) error {
133- err := wait .Poll (retryInterval , timeout , func () (bool , error ) {
113+ return wait .Poll (retryInterval , timeout , func () (bool , error ) {
134114 pod , err := tc .K8sClient .CoreV1 ().Pods (namespace ).Get (name , metav1.GetOptions {})
135115 if err != nil {
136116 return false , err
@@ -141,11 +121,7 @@ func (tc *TestClient) WaitForOperatorDeployment(t *testing.T, name, namespace st
141121 if pod .Status .Phase == corev1 .PodRunning {
142122 return true , nil
143123 }
144- t .Logf ("Pod %s Status: %s" , pod .Name , pod .Status .Phase )
124+ t .Logf ("Waiting for pod %s to get running, Current Status: %s\n " , pod .Name , pod .Status .Phase )
145125 return false , nil
146126 })
147- if err != nil {
148- return err
149- }
150- return nil
151127}
0 commit comments