Commit e0b3609 add more tests

4 files Authored and Committed by Susant Sahani a year ago
add more tests

    
  1 @@ -70,6 +70,15 @@
  2                   for key in kwargs:
  3                       self.assertRegex(contents, kwargs[key])
  4   
  5 +                 in_file.close()
  6 + 
  7 +     def EnableIPForwarding(self):
  8 + 
  9 +         with open('/proc/sys/net/ipv6/conf/veth-peer/forwarding', 'a') as the_file:
 10 +             the_file.write('1')
 11 + 
 12 +             the_file.close()
 13 + 
 14       def SetupVethInterface(self):
 15           """Setup veth interface"""
 16   
 17 @@ -81,12 +90,16 @@
 18   
 19           ip.link('set', index=idx_veth_test, address='02:01:02:03:04:08')
 20           ip.link('set', index=idx_veth_peer, address='02:01:02:03:04:09')
 21 + 
 22           ip.link('set', index=idx_veth_test, state='up')
 23           ip.link('set', index=idx_veth_peer, state='up')
 24 -         ip.addr('add', index=idx_veth_peer, address='192.168.111.50')
 25   
 26           ip.close()
 27   
 28 +         self.EnableIPForwarding()
 29 + 
 30 +         time.sleep(10)
 31 + 
 32       def TearDownVethInterface(self):
 33   
 34           ip = IPRoute()
 35 @@ -103,47 +116,104 @@
 36           self.StopDaemon(RADVD_PID_FILE)
 37           self.TearDownVethInterface()
 38   
 39 +     def test_libtool_gets_default_router_preference(self):
 40 +         """ ndptool gets router preference  """
 41 + 
 42 +         self.StartRadvd()
 43 + 
 44 +         time.sleep(10)
 45 + 
 46 +         self.StartNDPTool()
 47 + 
 48 +         time.sleep(30)
 49 + 
 50 +         self.StopNDPTool()
 51 + 
 52 +         self.findTextInFile(NDPTOOL_CI_LOG,
 53 +                             router_pref='Default router preference: high')
 54 + 
 55 +     def test_libtool_gets_link_source_address(self):
 56 +         """ ndptool gets link source address  """
 57 + 
 58 +         self.StartRadvd()
 59 + 
 60 +         time.sleep(10)
 61 + 
 62 +         self.StartNDPTool()
 63 + 
 64 +         time.sleep(30)
 65 + 
 66 +         self.StopNDPTool()
 67 + 
 68 +         self.findTextInFile(NDPTOOL_CI_LOG,
 69 +                             source_link_addr='Source linkaddr: 02:01:02:03:04:09')
 70 + 
 71 +     def test_libtool_gets_lifetime(self):
 72 +         """ ndptool gets lifetime  """
 73 + 
 74 +         self.StartRadvd()
 75 + 
 76 +         time.sleep(10)
 77 + 
 78 +         self.StartNDPTool()
 79 + 
 80 +         time.sleep(30)
 81 + 
 82 +         self.StopNDPTool()
 83 + 
 84 +         self.findTextInFile(NDPTOOL_CI_LOG,
 85 +                             prefix='Prefix: 2001:db8:1::/64, valid_time: 30s, preferred_time: 30s',
 86 +                             dns_lifetime='Recursive DNS Servers: 2001:db8::1, 2001:db8::2, lifetime: 15s',
 87 +                             search_lifetime='DNS Search List: branch.example.com example.com, lifetime: 15s',
 88 +                             router_lifetime='Router lifetime: 30s')
 89 + 
 90       def test_libtool_gets_mtu(self):
 91 -         """ libndp gets the RDNSS DNSSL """
 92 +         """ ndptool gets MTU=1280 """
 93   
 94           self.StartRadvd()
 95   
 96 -         time.sleep(1)
 97 +         time.sleep(10)
 98   
 99           self.StartNDPTool()
100   
101 -         time.sleep(5)
102 +         time.sleep(30)
103 + 
104 +         self.StopNDPTool()
105 + 
106           self.findTextInFile(NDPTOOL_CI_LOG,
107 -                             Prefix='Prefix: 2001:db8:1::/64, valid_time: 600s, preferred_time: 600s, on_link: yes',
108 -                             search='MTU: 1280')
109 +                             prefix='Prefix: 2001:db8:1::/64',
110 +                             mtu='MTU: 1280')
111   
112       def test_libtool_gets_rdnss_dnssl(self):
113 -         """ libndp gets the RDNSS DNSSL """
114 +         """ ndptool gets the RDNSS DNSSL """
115   
116           self.StartRadvd()
117   
118 -         time.sleep(1)
119 +         time.sleep(10)
120   
121           self.StartNDPTool()
122   
123 -         time.sleep(5)
124 +         time.sleep(30)
125 + 
126 +         self.StopNDPTool()
127 + 
128           self.findTextInFile(NDPTOOL_CI_LOG,
129 -                             Prefix='Prefix: 2001:db8:1::/64, valid_time: 600s, preferred_time: 600s, on_link: yes',
130 -                             rdnss='Recursive DNS Servers: 2001:db8::1, 2001:db8::2, lifetime: 30s',
131 -                             dnssl='DNS Search List: branch.example.com example.com, lifetime: 40s')
132 +                             Prefix='Prefix: 2001:db8:1::/64',
133 +                             rdnss='Recursive DNS Servers: 2001:db8::1, 2001:db8::2',
134 +                             dnssl='DNS Search List: branch.example.com example.com')
135   
136       def test_libtool_gets_prefix(self):
137   
138           self.StartRadvd()
139   
140 -         time.sleep(2)
141 +         time.sleep(10)
142   
143           self.StartNDPTool()
144 -         time.sleep(5)
145 +         time.sleep(10)
146           self.StopNDPTool()
147   
148           self.findTextInFile(NDPTOOL_CI_LOG,
149 -                             Prefix='Prefix: 2001:db8:1::/64, valid_time: 600s, preferred_time: 600s, on_link: yes')
150 +                             prefix='Prefix: 2001:db8:1::/64')
151   
152   if __name__ == '__main__':
153       unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
1 @@ -6,5 +6,6 @@
2   Type=simple
3   ExecStart=/usr/bin/ndptool monitor -i veth-test
4   StandardOutput=file:/var/run/libndp-ci/ndptool.log
5 + 
6   [Install]
7   WantedBy=multi-user.target
 1 @@ -1,12 +1,13 @@
 2   interface veth-peer
 3   {
 4 +         AdvManagedFlag on;
 5 +         AdvSendAdvert on;
 6 +         AdvLinkMTU 1280;
 7   
 8 - AdvManagedFlag on;
 9 - AdvSendAdvert on;
10 - MinRtrAdvInterval 30;
11 - MaxRtrAdvInterval 30;
12 - AdvLinkMTU 1280;
13 - AdvDefaultLifetime 30;
14 +         MaxRtrAdvInterval 15;
15 +         AdvDefaultLifetime 30;
16 + 
17 +         AdvDefaultPreference high;
18   
19        prefix 2001:db8:1:0::/64
20        {
21 @@ -22,7 +23,7 @@
22   #
23           RDNSS 2001:db8::1 2001:db8::2
24           {
25 -                 AdvRDNSSLifetime 30;
26 +                 AdvRDNSSLifetime 15;
27           };
28   
29   #
30 @@ -30,7 +31,6 @@
31   #
32           DNSSL branch.example.com example.com
33           {
34 -                 AdvDNSSLLifetime 30;
35 +                 AdvDNSSLLifetime 15;
36           };
37 - 
38   };
 1 @@ -2,12 +2,13 @@
 2     roles:
 3       - role: standard-test-beakerlib
 4         tags:
 5 -       - classic
 6 +         - classic
 7         tests:
 8 -       - ndp-tests
 9 -   required_packages:
10 -       - radvd
11 -       - python3
12 -       - systemd
13 -       - libndp
14 -       - python3-pyroute2
15 +         - ndp-tests
16 +       required_packages:
17 +         - python3
18 +         - systemd
19 +         - iproute
20 +         - python3-pyroute2
21 +         - libndp
22 +         - radvd