Skip to content

Commit 40e8031

Browse files
test(vm): add virtualization-dra check
Signed-off-by: Yaroslav Borbat <yaroslav.borbat@flant.com>
1 parent ddd7cda commit 40e8031

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

  • test/e2e/internal/precheck

test/e2e/internal/precheck/usb.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525

2626
"github.com/deckhouse/virtualization/test/e2e/internal/framework"
27+
k8serrors "k8s.io/apimachinery/pkg/api/errors"
2728
)
2829

2930
const (
@@ -49,7 +50,7 @@ func checkDummyHCDConfigured(ctx context.Context, f *framework.Framework) bool {
4950

5051
nodeUSBList, err := virtClient.NodeUSBDevices().List(ctx, metav1.ListOptions{})
5152
if err != nil {
52-
_, _ = fmt.Fprintf(GinkgoWriter, "failed to list NodeUSBDevices: %v\n", err)
53+
GinkgoWriter.Printf("failed to list NodeUSBDevices: %v\n", err)
5354
return false
5455
}
5556

@@ -62,6 +63,19 @@ func checkDummyHCDConfigured(ctx context.Context, f *framework.Framework) bool {
6263
return false
6364
}
6465

66+
func (u *usbPrecheck) checkVirtualizationDraRunning(ctx context.Context, f *framework.Framework) bool {
67+
_, err := f.KubeClient().AppsV1().DaemonSets(metav1.NamespaceSystem).Get(ctx, "virtualization-dra", metav1.GetOptions{})
68+
if err != nil {
69+
if k8serrors.IsNotFound(err) {
70+
return false
71+
}
72+
GinkgoWriter.Printf("failed to get virtualization-dra DaemonSet: %v\n", err)
73+
return false
74+
}
75+
return true
76+
77+
}
78+
6579
func (u *usbPrecheck) Run(ctx context.Context, f *framework.Framework) error {
6680
if !isCheckEnabled(usbPrecheckEnvName) {
6781
_, _ = GinkgoWriter.Write([]byte("USB precheck is disabled.\n"))
@@ -73,6 +87,11 @@ func (u *usbPrecheck) Run(ctx context.Context, f *framework.Framework) error {
7387
"Run generate_dummy_hcd_ngc.sh to configure dummy_hcd USB device", usbPrecheckEnvName)
7488
}
7589

90+
if !u.checkVirtualizationDraRunning(ctx, f) {
91+
return fmt.Errorf("%s=no to disable this precheck: virtualization-dra DaemonSet is not running. "+
92+
"Configure virtualization with dra support", usbPrecheckEnvName)
93+
}
94+
7695
return nil
7796
}
7897

0 commit comments

Comments
 (0)