@@ -1711,6 +1711,54 @@ var _ = Describe("[sriov] operator", Ordered, func() {
17111711 })
17121712 })
17131713
1714+ Context ("Daemon reset with shutdown" , Ordered , func () {
1715+ var testNode string
1716+ var policy * sriovv1.SriovNetworkNodePolicy
1717+ resourceName := "resetresource"
1718+
1719+ BeforeAll (func () {
1720+ isSingleNode , err := cluster .IsSingleNode (clients )
1721+ Expect (err ).ToNot (HaveOccurred ())
1722+ if isSingleNode {
1723+ Skip ("test not supported for single node" )
1724+ }
1725+
1726+ sriovInfos , err := cluster .DiscoverSriov (clients , operatorNamespace )
1727+ Expect (err ).ToNot (HaveOccurred ())
1728+ Expect (len (sriovInfos .Nodes )).ToNot (BeZero ())
1729+ testNode = sriovInfos .Nodes [0 ]
1730+ iface , err := sriovInfos .FindOneSriovDevice (testNode )
1731+ Expect (err ).ToNot (HaveOccurred ())
1732+
1733+ policy , err = network .CreateSriovPolicy (clients , "test-policy-" , operatorNamespace , iface .Name , testNode , 5 , resourceName , "netdevice" )
1734+ Expect (err ).ToNot (HaveOccurred ())
1735+ WaitForSRIOVStable ()
1736+ })
1737+
1738+ It ("should remove interface configuration from host even after reboot" , func () {
1739+ By ("force rebooting the node" )
1740+ _ , errOutput , err := runCommandOnConfigDaemon (testNode , "chroot" , "/host" , "reboot" )
1741+ Expect (err ).ToNot (HaveOccurred (), errOutput )
1742+ By ("removing the policy" )
1743+ err = clients .Delete (context .Background (), policy )
1744+ Expect (err ).ToNot (HaveOccurred ())
1745+
1746+ By ("waiting for node to be not ready" )
1747+ waitForNodeCondition (testNode , corev1 .NodeReady , corev1 .ConditionFalse )
1748+
1749+ By ("waiting for node to be ready" )
1750+ waitForNodeCondition (testNode , corev1 .NodeReady , corev1 .ConditionTrue )
1751+
1752+ WaitForSRIOVStable ()
1753+ By ("Checking files on the host" )
1754+ output , errOutput , err := runCommandOnConfigDaemon (testNode , "/bin/bash" , "-c" , "ls /host/etc/sriov-operator/pci/ | wc -l" )
1755+ Expect (err ).ToNot (HaveOccurred (), errOutput )
1756+ Expect (strings .HasPrefix (output , "0" )).Should (BeTrue ())
1757+ output , errOutput , err = runCommandOnConfigDaemon (testNode , "/bin/bash" , "-c" , "ls /host/etc/udev/rules.d/ | grep 10-nm-disable | wc -l" )
1758+ Expect (err ).ToNot (HaveOccurred (), errOutput )
1759+ Expect (strings .HasPrefix (output , "0" )).Should (BeTrue ())
1760+ })
1761+ })
17141762 })
17151763})
17161764
@@ -2403,3 +2451,16 @@ func getInterfaceFromNodeStateByPciAddress(node, pciAddress string) *sriovv1.Int
24032451 Expect (found ).To (BeTrue ())
24042452 return intf
24052453}
2454+
2455+ func waitForNodeCondition (nodeName string , conditionType corev1.NodeConditionType , conditionStatus corev1.ConditionStatus ) {
2456+ EventuallyWithOffset (1 , func (g Gomega ) bool {
2457+ node , err := clients .CoreV1Interface .Nodes ().Get (context .Background (), nodeName , metav1.GetOptions {})
2458+ g .Expect (err ).ToNot (HaveOccurred ())
2459+ for _ , con := range node .Status .Conditions {
2460+ if con .Type == conditionType && con .Status == conditionStatus {
2461+ return true
2462+ }
2463+ }
2464+ return false
2465+ }, waitingTime , 1 * time .Second ).Should (BeTrue ())
2466+ }
0 commit comments