Merge "Move dlux Sonar scan to Sonarcloud"
[releng/builder.git] / jjb / packaging / test-karaf-oxygensafe.expect
1 #!/usr/bin/expect
2 # This script starts the Karaf shell and sends the password for SSH auth.
3 # Further tests in Karaf shell can be done here
4
5 # Echo commands
6 log_user 1
7
8 # Time expect will wait for output
9 set timeout 30
10
11 # Default password
12 set password "karaf"
13 # Default prompt
14 set prompt "opendaylight-user@root>"
15
16 # Wait for Karaf SSH server to come online
17 send_user "Waiting on OpenDaylight to start listening for SSH on port 8101\n"
18 exec bash -c "while ! nmap -Pn -p8101 localhost | grep -q open; do sleep 0.1; done"
19
20 # SSH into Karaf shell
21 send_user "SSH into ODL Karaf shell\n"
22 spawn ssh -p 8101 -o StrictHostKeyChecking=no karaf@127.0.0.1
23
24 # Auth to Karaf shell
25 expect "Password authentication"
26 expect "Password: "
27 send "$password\r"
28
29 # Show features to make debugging easier
30 # Check for "No features available" error message
31 expect "$prompt"
32 send "feature:list\r"
33 expect {{
34   timeout {{
35     send_user "\nFeatures seem to be available\n"
36   }}
37   "No features available" {{
38     send_user "\nNo features available, error\n"
39     exit 1
40   }}
41 }}
42
43 # Verify that a major feature is present
44 expect "$prompt"
45 send "feature:list | grep odl-netvirt-openstack\r"
46 expect {{
47   timeout {{
48     send_user "\nTest feature not found\n"
49     exit 1
50   }}
51   "OpenDaylight :: NetVirt :: OpenStack" {{
52     send_user "\nTest feature available\n"
53   }}
54 }}
55
56 # Disable this test until ODLPARENT-139 is fixed
57 # Install feature
58 # expect "$prompt"
59 # send "feature:install odl-netvirt-openstack\r"
60 # expect {{
61 #   "Error executing command: Can't install feature" {{
62 #     send_user "\nFailed to install test feature\n"
63 #     exit 1
64 #   }}
65 # }}
66
67 # Verify installed feature is actually installed
68 # expect "$prompt"
69 # The -i flag will only show installed features
70 # send "feature:list -i | grep odl-netvirt-openstack\r"
71 # expect {{
72 #   timeout {{
73 #     send_user "\nTest feature not installed\n"
74 #     exit 1
75 #   }}
76 #   "OpenDaylight :: NetVirt :: OpenStack" {{
77 #     send_user "\nTest feature installed successfully\n"
78 #   }}
79 # }}
80
81 send_user "End of Karaf shell tests\n"