#!/usr/bin/expect # This script starts the Karaf shell and sends the password for SSH auth. # Further tests in Karaf shell can be done here # Echo commands log_user 1 # Time expect will wait for output set timeout 30 # Default password set password "karaf" # Default prompt set prompt "opendaylight-user@root>" # Wait for Karaf SSH server to come online send_user "Waiting on OpenDaylight to start listening for SSH on port 8101\n" exec bash -c "while ! nmap -Pn -p8101 localhost | grep -q open; do sleep 0.1; done" # SSH into Karaf shell send_user "SSH into ODL Karaf shell\n" spawn ssh -p 8101 -o StrictHostKeyChecking=no karaf@127.0.0.1 # Auth to Karaf shell expect "Password authentication" expect "Password: " send "$password\r" # Show features to make debugging easier # Check for "No features available" error message expect "$prompt" send "feature:list\r" expect {{ timeout {{ send_user "\nFeatures seem to be available\n" }} "No features available" {{ send_user "\nNo features available, error\n" exit 1 }} }} # Verify that a major feature is present expect "$prompt" send "feature:list | grep odl-netvirt-openstack\r" expect {{ timeout {{ send_user "\nTest feature not found\n" exit 1 }} "OpenDaylight :: NetVirt :: OpenStack" {{ send_user "\nTest feature available\n" }} }} # Disable this test until ODLPARENT-139 is fixed # Install feature # expect "$prompt" # send "feature:install odl-netvirt-openstack\r" # expect {{ # "Error executing command: Can't install feature" {{ # send_user "\nFailed to install test feature\n" # exit 1 # }} # }} # Verify installed feature is actually installed # expect "$prompt" # The -i flag will only show installed features # send "feature:list -i | grep odl-netvirt-openstack\r" # expect {{ # timeout {{ # send_user "\nTest feature not installed\n" # exit 1 # }} # "OpenDaylight :: NetVirt :: OpenStack" {{ # send_user "\nTest feature installed successfully\n" # }} # }} send_user "End of Karaf shell tests\n"