@@ -1722,6 +1722,72 @@ var _ = Describe("[sriov] operator", func() {
17221722 })
17231723 })
17241724
1725+ Context ("Daemon reset with shutdown" , Ordered , func () {
1726+ var testNode string
1727+ var policy * sriovv1.SriovNetworkNodePolicy
1728+ resourceName := "resetresource"
1729+
1730+ BeforeAll (func () {
1731+ isSingleNode , err := cluster .IsSingleNode (clients )
1732+ Expect (err ).ToNot (HaveOccurred ())
1733+ if isSingleNode {
1734+ Skip ("test not supported for single node" )
1735+ }
1736+
1737+ sriovInfos , err := cluster .DiscoverSriov (clients , operatorNamespace )
1738+ Expect (err ).ToNot (HaveOccurred ())
1739+ Expect (len (sriovInfos .Nodes )).ToNot (BeZero ())
1740+ testNode = sriovInfos .Nodes [0 ]
1741+ iface , err := sriovInfos .FindOneSriovDevice (testNode )
1742+ Expect (err ).ToNot (HaveOccurred ())
1743+
1744+ policy , err = network .CreateSriovPolicy (clients , "test-policy-" , operatorNamespace , iface .Name , testNode , 5 , resourceName , "netdevice" )
1745+ Expect (err ).ToNot (HaveOccurred ())
1746+ WaitForSRIOVStable ()
1747+ })
1748+
1749+ It ("should remove interface configuration from host even after reboot" , func () {
1750+ By ("force rebooting the node" )
1751+ _ , errOutput , err := runCommandOnConfigDaemon (testNode , "chroot" , "/host" , "reboot" )
1752+ Expect (err ).ToNot (HaveOccurred (), errOutput )
1753+ By ("removing the policy" )
1754+ err = clients .Delete (context .Background (), policy )
1755+ Expect (err ).ToNot (HaveOccurred ())
1756+
1757+ By ("waiting for node to be not ready" )
1758+ Eventually (func (g Gomega ) bool {
1759+ node , err := clients .CoreV1Interface .Nodes ().Get (context .Background (), testNode , metav1.GetOptions {})
1760+ g .Expect (err ).ToNot (HaveOccurred ())
1761+ for _ , con := range node .Status .Conditions {
1762+ if con .Type == corev1 .NodeReady && con .Status != corev1 .ConditionTrue {
1763+ return true
1764+ }
1765+ }
1766+ return false
1767+ }, waitingTime , 1 * time .Second ).Should (BeTrue ())
1768+
1769+ By ("waiting for node to be ready" )
1770+ Eventually (func (g Gomega ) bool {
1771+ node , err := clients .CoreV1Interface .Nodes ().Get (context .Background (), testNode , metav1.GetOptions {})
1772+ g .Expect (err ).ToNot (HaveOccurred ())
1773+ for _ , con := range node .Status .Conditions {
1774+ if con .Type == corev1 .NodeReady && con .Status == corev1 .ConditionTrue {
1775+ return true
1776+ }
1777+ }
1778+ return false
1779+ }, waitingTime , 1 * time .Second ).Should (BeTrue ())
1780+
1781+ WaitForSRIOVStable ()
1782+ By ("Checking files on the host" )
1783+ output , errOutput , err := runCommandOnConfigDaemon (testNode , "/bin/bash" , "-c" , "ls /host/etc/sriov-operator/pci/ | wc -l" )
1784+ Expect (err ).ToNot (HaveOccurred (), errOutput )
1785+ Expect (strings .HasPrefix (output , "0" )).Should (BeTrue ())
1786+ output , errOutput , err = runCommandOnConfigDaemon (testNode , "/bin/bash" , "-c" , "ls /host/etc/udev/rules.d/ | grep 10-nm-disable | wc -l" )
1787+ Expect (err ).ToNot (HaveOccurred (), errOutput )
1788+ Expect (strings .HasPrefix (output , "0" )).Should (BeTrue ())
1789+ })
1790+ })
17251791 })
17261792})
17271793
0 commit comments