Skip to content

Commit b80c553

Browse files
committed
add clean pools and pools CR to reporter for functional tests
Signed-off-by: Sebastian Sch <[email protected]>
1 parent 97c5453 commit b80c553

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

test/util/k8sreporter/reporter.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"strings"
77

88
kniK8sReporter "github.com/openshift-kni/k8sreporter"
9+
rbacv1 "k8s.io/api/rbac/v1"
910
"k8s.io/apimachinery/pkg/runtime"
1011

12+
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
13+
1114
sriovv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
1215
"github.com/k8snetworkplumbingwg/sriov-network-operator/test/util/namespaces"
13-
14-
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
15-
rbacv1 "k8s.io/api/rbac/v1"
1616
)
1717

1818
func New(reportPath string) (*kniK8sReporter.KubernetesReporter, error) {
@@ -63,6 +63,7 @@ func New(reportPath string) (*kniK8sReporter.KubernetesReporter, error) {
6363
{Cr: &sriovv1.SriovNetworkNodePolicyList{}},
6464
{Cr: &sriovv1.SriovNetworkList{}},
6565
{Cr: &sriovv1.SriovOperatorConfigList{}},
66+
{Cr: &sriovv1.SriovNetworkPoolConfigList{}},
6667
{Cr: &monitoringv1.ServiceMonitorList{}, Namespace: &operatorNamespace},
6768
{Cr: &monitoringv1.PrometheusRuleList{}, Namespace: &operatorNamespace},
6869
{Cr: &rbacv1.RoleList{}, Namespace: &operatorNamespace},

test/util/namespaces/namespaces.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,25 @@ func CleanNetworks(operatorNamespace string, cs *testclient.ClientSet) error {
129129
return waitForSriovNetworkDeletion(operatorNamespace, cs, 15*time.Second)
130130
}
131131

132+
func CleanPools(operatorNamespace string, cs *testclient.ClientSet) error {
133+
pools := sriovv1.SriovNetworkPoolConfigList{}
134+
err := cs.List(context.Background(),
135+
&pools,
136+
runtimeclient.InNamespace(operatorNamespace))
137+
if err != nil {
138+
return err
139+
}
140+
for _, p := range pools.Items {
141+
if strings.HasPrefix(p.Name, "test-") {
142+
err := cs.Delete(context.Background(), &p)
143+
if err != nil {
144+
return fmt.Errorf("failed to delete networkPoolConfig %v", err)
145+
}
146+
}
147+
}
148+
return err
149+
}
150+
132151
func waitForSriovNetworkDeletion(operatorNamespace string, cs *testclient.ClientSet, timeout time.Duration) error {
133152
return wait.PollImmediate(time.Second, timeout, func() (bool, error) {
134153
networks := sriovv1.SriovNetworkList{}
@@ -164,7 +183,8 @@ func Clean(operatorNamespace, namespace string, cs *testclient.ClientSet, discov
164183
if err != nil {
165184
return err
166185
}
167-
return nil
186+
187+
return CleanPools(operatorNamespace, cs)
168188
}
169189

170190
func AddLabel(cs corev1client.NamespacesGetter, ctx context.Context, namespaceName, key, value string) error {

0 commit comments

Comments
 (0)