def test_install_configure_start(self, setup_tester_ssh_connection, mender_dist_packages_versions, mender_version): result = setup_tester_ssh_connection.run('uname -a') assert "raspberrypi" in result.stdout upload_deb_package(setup_tester_ssh_connection, mender_dist_packages_versions["mender-client"]) # Install the package using the following flow in the wizard: # Device type (for example raspberrypi3-raspbian): rasbperrytest # Confirm devicetype as rasbperrytest? [Y/n] y # Are you connecting this device to Hosted Mender? [Y/n] n # Do you want to run the client in demo mode? [Y/n] y # Set the IP of the Mender Server: [127.0.0.1] 1.2.3.4 result = setup_tester_ssh_connection.run('sudo dpkg -i ' + package_filename(mender_dist_packages_versions["mender-client"]) + """ <<STDIN rasbperrytest y n y 1.2.3.4 STDIN""") assert "Unpacking mender-client (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout assert "Setting up mender-client (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout self.check_mender_client_version(setup_tester_ssh_connection, mender_version, mender_dist_packages_versions["mender-client"]) self.check_installed_files(setup_tester_ssh_connection, "rasbperrytest") # Demo setup expects ServerURL docker.mender.io with IP address in /etc/hosts result = setup_tester_ssh_connection.run('cat /etc/mender/mender.conf') assert '"ServerURL": "https://docker.mender.io"' in result.stdout result = setup_tester_ssh_connection.run('cat /etc/hosts') assert re.match(r".*1\.2\.3\.4\s*docker\.mender\.io.*", result.stdout, re.DOTALL) is not None self.check_systemd_start_full_cycle(setup_tester_ssh_connection)
def test_mender_gateway(self, setup_tester_ssh_connection, mender_dist_packages_versions): # Upload upload_deb_package( setup_tester_ssh_connection, mender_dist_packages_versions["mender-gateway"], "mender-gateway", ) # Install result = setup_tester_ssh_connection.run( "sudo DEBIAN_FRONTEND=noninteractive dpkg -i " + package_filename( mender_dist_packages_versions["mender-gateway"], "mender-gateway", )) assert ("Unpacking mender-gateway (" + mender_dist_packages_versions["mender-gateway"] + ")" in result.stdout) assert ("Setting up mender-gateway (" + mender_dist_packages_versions["mender-gateway"] + ")" in result.stdout) # Check mender-gateway files setup_tester_ssh_connection.run("test -x /usr/bin/mender-gateway") setup_tester_ssh_connection.run( "test -f /etc/mender/mender-gateway.conf") setup_tester_ssh_connection.run( "test -f /lib/systemd/system/mender-gateway.service")
def test_mender_client_service_starts_after_reboot( self, setup_test_container, setup_tester_ssh_connection, mender_dist_packages_versions, ): conn = setup_tester_ssh_connection upload_deb_package(conn, mender_dist_packages_versions["mender-client"]) conn.run( "sudo DEBIAN_FRONTEND=noninteractive dpkg -i " + package_filename(mender_dist_packages_versions["mender-client"])) # Reboot in the background, so that SSH can exit properly conn.run("sleep 1 && sudo reboot &") # Wait for the reboot to actually start before calling wait_for_container_boot time.sleep(10) wait_for_container_boot(setup_test_container.container_id) # Check first that mender process is running result = conn.run("pgrep mender") assert result.exited == 0 result = conn.run("sudo journalctl -u mender-client --no-pager") # Check Mender service start after device reboot assert "Started Mender OTA update service." in result.stdout assert "Loaded configuration file" in result.stdout assert "No dual rootfs configuration present" in result.stdout
def test_install_configure_start(self, setup_tester_ssh_connection, mender_dist_packages_versions, mender_version): result = setup_tester_ssh_connection.run("uname -a") assert "raspberrypi" in result.stdout upload_deb_package(setup_tester_ssh_connection, mender_dist_packages_versions["mender-client"]) # Install the deb package. On failure, install the missing dependencies. result = setup_tester_ssh_connection.run( "sudo DEBIAN_FRONTEND=noninteractive dpkg -i " + package_filename(mender_dist_packages_versions["mender-client"]) + "|| sudo apt-get -f -y install") assert ("Unpacking mender-client (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout) assert ("Setting up mender-client (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout) self.check_mender_client_version( setup_tester_ssh_connection, mender_version, mender_dist_packages_versions["mender-client"], ) self.check_installed_files(setup_tester_ssh_connection, "raspberrypi") # Default setup expects ServerURL hosted.mender.io result = setup_tester_ssh_connection.sudo( "cat /etc/mender/mender.conf") assert '"ServerURL": "https://hosted.mender.io"' in result.stdout self.check_systemd_start_full_cycle(setup_tester_ssh_connection)
def test_install_configure_start( self, setup_tester_ssh_connection, mender_dist_packages_versions, mender_version ): result = setup_tester_ssh_connection.run("uname -a") assert "raspberrypi" in result.stdout upload_deb_package( setup_tester_ssh_connection, mender_dist_packages_versions["mender-client"] ) # Install the package using the following flow for "mender setup": # ... # Enter a name for the device type (e.g. raspberrypi3): [raspberrypi] raspberrytest # Are you connecting this device to hosted.mender.io? [Y/n] n # Do you want to run the client in demo mode? [Y/n] y # Set the IP of the Mender Server: [127.0.0.1] 1.2.3.4 # Mender setup successfully. # ... result = setup_tester_ssh_connection.run( "sudo dpkg -i " + package_filename(mender_dist_packages_versions["mender-client"]) + """ <<STDIN raspberrytest n y 1.2.3.4 STDIN""" ) assert ( "Unpacking mender-client (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout ) assert ( "Setting up mender-client (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout ) self.check_mender_client_version(setup_tester_ssh_connection, mender_version) self.check_installed_files(setup_tester_ssh_connection, "raspberrytest") # Demo setup expects ServerURL docker.mender.io with IP address in /etc/hosts result = setup_tester_ssh_connection.sudo("cat /etc/mender/mender.conf") assert '"ServerURL": "https://docker.mender.io"' in result.stdout result = setup_tester_ssh_connection.run("cat /etc/hosts") assert ( re.match(r".*1\.2\.3\.4\s*docker\.mender\.io.*", result.stdout, re.DOTALL) is not None ) self.check_systemd_start_full_cycle(setup_tester_ssh_connection)
def test_mender_connect( self, setup_tester_ssh_connection, mender_dist_packages_versions, mender_connect_version, ): # Upload upload_deb_package( setup_tester_ssh_connection, mender_dist_packages_versions["mender-connect"], "mender-connect", ) # Install result = setup_tester_ssh_connection.run( "sudo DEBIAN_FRONTEND=noninteractive dpkg -i " + package_filename( mender_dist_packages_versions["mender-connect"], "mender-connect" ) ) assert ( "Unpacking mender-connect (" + mender_dist_packages_versions["mender-connect"] + ")" in result.stdout ) assert ( "Setting up mender-connect (" + mender_dist_packages_versions["mender-connect"] + ")" in result.stdout ) # Check mender-connect files setup_tester_ssh_connection.run("test -x /usr/bin/mender-connect") setup_tester_ssh_connection.run("test -f /etc/mender/mender-connect.conf") setup_tester_ssh_connection.run( "test -f /lib/systemd/system/mender-connect.service" ) # Check mender-configure version if mender_connect_version == "master": # For master it will print the short git hash. We can obtain this from the deb # package version, which is something like: "0.0~git20191022.dade697-1" m = re.match( r"[0-9]+\.[0-9]+\.[0-9]+~git[0-9]+\.([a-z0-9]+)-1", mender_dist_packages_versions["mender-connect"], ) assert m is not None else: result = setup_tester_ssh_connection.run("mender-connect version") assert mender_connect_version in result.stdout
def test_mender_client_dev(self, setup_tester_ssh_connection, mender_dist_packages_versions): # Upload upload_deb_package( setup_tester_ssh_connection, mender_dist_packages_versions["mender-client"], "mender-client", ) upload_deb_package( setup_tester_ssh_connection, mender_dist_packages_versions["mender-client"], "mender-client-dev", package_arch="all", ) # Install result = setup_tester_ssh_connection.run( "sudo DEBIAN_FRONTEND=noninteractive dpkg -i " + package_filename( mender_dist_packages_versions["mender-client"], "mender-client", ) + " " + package_filename( mender_dist_packages_versions["mender-client"], "mender-client-dev", package_arch="all", )) assert ("Unpacking mender-client-dev (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout) assert ("Setting up mender-client-dev (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout) # Check mender-client-dev files setup_tester_ssh_connection.run( "test -f /usr/share/dbus-1/interfaces/io.mender.Authentication1.xml" )
def test_mender_monitor( self, setup_tester_ssh_connection, mender_dist_packages_versions ): # Upload upload_deb_package( setup_tester_ssh_connection, mender_dist_packages_versions["mender-monitor"], "mender-monitor", "all", ) # Install the lmdb-utils result = setup_tester_ssh_connection.run( "sudo DEBIAN_FRONTEND=noninteractive apt-get install -f -y " + "lmdb-utils" ) assert result.exited == 0 # Install result = setup_tester_ssh_connection.run( "sudo DEBIAN_FRONTEND=noninteractive dpkg -i " + package_filename( mender_dist_packages_versions["mender-monitor"], "mender-monitor", "all", ) ) assert ( "Unpacking mender-monitor (" + mender_dist_packages_versions["mender-monitor"] + ")" in result.stdout ) assert ( "Setting up mender-monitor (" + mender_dist_packages_versions["mender-monitor"] + ")" in result.stdout ) # Check mender-monitor files setup_tester_ssh_connection.run( "test -x /usr/share/mender-monitor/mender-monitord" ) setup_tester_ssh_connection.run("test -x /etc/mender-monitor/monitor.d/log.sh")
def test_mender_configure( self, setup_tester_ssh_connection, mender_dist_packages_versions ): # Upload upload_deb_package( setup_tester_ssh_connection, mender_dist_packages_versions["mender-configure"], "mender-configure", "all", ) # Install result = setup_tester_ssh_connection.run( "sudo DEBIAN_FRONTEND=noninteractive dpkg -i " + package_filename( mender_dist_packages_versions["mender-configure"], "mender-configure", "all", ) ) assert ( "Unpacking mender-configure (" + mender_dist_packages_versions["mender-configure"] + ")" in result.stdout ) assert ( "Setting up mender-configure (" + mender_dist_packages_versions["mender-configure"] + ")" in result.stdout ) # Check mender-configure files setup_tester_ssh_connection.run( "test -x /usr/share/mender/modules/v3/mender-configure" ) setup_tester_ssh_connection.run( "test -x /usr/share/mender/inventory/mender-inventory-mender-configure" )
def test_install_configure_start(self, setup_tester_ssh_connection, mender_dist_packages_versions, mender_version): result = setup_tester_ssh_connection.run('uname -a') assert "raspberrypi" in result.stdout upload_deb_package(setup_tester_ssh_connection, mender_dist_packages_versions["mender-client"]) result = setup_tester_ssh_connection.run('sudo DEBIAN_FRONTEND=noninteractive dpkg -i ' + package_filename(mender_dist_packages_versions["mender-client"])) assert "Unpacking mender-client (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout assert "Setting up mender-client (" + mender_dist_packages_versions["mender-client"] + ")" in result.stdout self.check_mender_client_version(setup_tester_ssh_connection, mender_version, mender_dist_packages_versions["mender-client"]) self.check_installed_files(setup_tester_ssh_connection) # Default setup expects ServerURL hosted.mender.io result = setup_tester_ssh_connection.run('cat /etc/mender/mender.conf') assert '"ServerURL": "https://hosted.mender.io"' in result.stdout self.check_systemd_start_full_cycle(setup_tester_ssh_connection)