Skip to content

Commit 6114d09

Browse files
claudioloradamjensenbot
authored andcommitted
test: add description in the uninstall checks of 2e2 tests
This patch adds the name of the remaining resources, when the post uninstall checks fail because of the presence of resources managed by Liqo after Liqo is actually uninstalled.
1 parent 5284147 commit 6114d09

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

test/e2e/postuninstall/basic_test.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package postuninstall
1717
import (
1818
"context"
1919
"fmt"
20+
"strings"
2021
"testing"
2122
"time"
2223

@@ -128,7 +129,11 @@ func NoLiqoNodes(ctx context.Context, clientset *kubernetes.Clientset) error {
128129
return err
129130
}
130131
if len(nodes.Items) > 0 {
131-
return fmt.Errorf("There are still virtual nodes in the cluster")
132+
nodesNames := make([]string, 0, len(nodes.Items))
133+
for i := range nodes.Items {
134+
nodesNames = append(nodesNames, nodes.Items[i].Name)
135+
}
136+
return fmt.Errorf("There are still the virtual nodes %q in the cluster", strings.Join(nodesNames, ", "))
132137
}
133138
return nil
134139
}
@@ -140,7 +145,11 @@ func NoRoles(ctx context.Context, cl client.Client, namespaces []string, lSelect
140145
return err
141146
}
142147
if len(roles) > 0 {
143-
return fmt.Errorf("There are still roles in namespace %s matching the selector", namespace)
148+
rolesNames := make([]string, 0, len(roles))
149+
for i := range roles {
150+
rolesNames = append(rolesNames, roles[i].Name)
151+
}
152+
return fmt.Errorf("There are still the roles %q in namespace %s matching the selector", strings.Join(rolesNames, ", "), namespace)
144153
}
145154
}
146155
return nil
@@ -153,7 +162,11 @@ func NoRoleBindings(ctx context.Context, cl client.Client, namespaces []string,
153162
return err
154163
}
155164
if len(roleBindings) > 0 {
156-
return fmt.Errorf("There are still rolebindings in namespace %s matching the selector", namespace)
165+
roleBindingNames := make([]string, 0, len(roleBindings))
166+
for i := range roleBindings {
167+
roleBindingNames = append(roleBindingNames, roleBindings[i].Name)
168+
}
169+
return fmt.Errorf("There are still the rolebindings %q in namespace %s matching the selector", strings.Join(roleBindingNames, ", "), namespace)
157170
}
158171
}
159172
return nil
@@ -165,7 +178,11 @@ func NoClusterRoles(ctx context.Context, cl client.Client, lSelector labels.Sele
165178
return err
166179
}
167180
if len(clusterRoles) > 0 {
168-
return fmt.Errorf("There are still clusterroles in the cluster matching the selector")
181+
clusterRolesNames := make([]string, 0, len(clusterRoles))
182+
for i := range clusterRoles {
183+
clusterRolesNames = append(clusterRolesNames, clusterRoles[i].Name)
184+
}
185+
return fmt.Errorf("There are still the clusterroles %q in the cluster matching the selector", strings.Join(clusterRolesNames, ", "))
169186
}
170187
return nil
171188
}
@@ -176,7 +193,12 @@ func NoClusterRoleBindings(ctx context.Context, cl client.Client, lSelector labe
176193
return err
177194
}
178195
if len(clusterRoleBindings) > 0 {
179-
return fmt.Errorf("There are still clusterrolebindings in the cluster matching the selector")
196+
clusterRoleBindingsNames := make([]string, 0, len(clusterRoleBindings))
197+
for i := range clusterRoleBindings {
198+
clusterRoleBindingsNames = append(clusterRoleBindingsNames, clusterRoleBindings[i].Name)
199+
}
200+
return fmt.Errorf("There are still the clusterrolebindings %q in the cluster matching the selector",
201+
strings.Join(clusterRoleBindingsNames, ", "))
180202
}
181203
return nil
182204
}

0 commit comments

Comments
 (0)