def test_simple_start_stop(): util.log('[START TEST] start daemonized container and kill it') cont_pid = aucont.start_daemonized(util.test_rootfs_path(), '/bin/sleep', '5') util.check(aucont.clist()[0] == cont_pid) aucont.stop(cont_pid, 9) util.check(len(aucont.clist()) == 0)
def test_simple_start_stop(): util.log('[START TEST] start daemonized container and kill it') cont_pid = aucont.start_daemonized( util.test_rootfs_path(), '/bin/sleep', '5' ) util.check(aucont.clist()[0] == cont_pid) aucont.stop(cont_pid, 9) util.check(len(aucont.clist()) == 0)
def test_host_user_uid_preserved(): util.log( '[START TEST] check that host uid and gid of container isn\'t changed') cont_pid = aucont.start_daemonized(util.test_rootfs_path(), '/bin/sleep', '5') cont_euid, cont_egid = util.get_pid_eids(cont_pid) aucont.stop(cont_pid, 9) util.check(os.geteuid() == cont_euid and os.getegid() == cont_egid)
def test_daemonization(): util.log("""[START_TEST] check that daemonized container doesn't use tty""") cont_pid = aucont.start_daemonized(util.test_rootfs_path(), '/test/interactive/bin/test') time.sleep(1) output = aucont.exec_capture_output(cont_pid, "/bin/cat", "/test/interactive/bin/result.txt") aucont.stop(cont_pid, 9) output = output.strip() util.debug(output) util.check(output != 'Ok')
def test_daemonization(): util.log("""[START_TEST] check that daemonized container doesn't use tty""") cont_pid = aucont.start_daemonized( util.test_rootfs_path(), '/test/interactive/bin/test' ) time.sleep(1) output = aucont.exec_capture_output( cont_pid, "/bin/cat", "/test/interactive/bin/result.txt" ) aucont.stop(cont_pid, 9) output = output.strip() util.debug(output) util.check(output != 'Ok')
def test_webserver(): util.log("""[START TEST] start container with enabled networking, run web server on priveledged port inside. Warning: stop network manager before running all network tests""") cont_ip = '192.168.1.1' cont_pid = aucont.start_daemonized(util.test_rootfs_path(), '/test/web/server.sh', '80', cont_ip=cont_ip) time.sleep(2) url = 'http://' + cont_ip + ':80/file.txt' http_resp = urlopen(url) aucont.stop(cont_pid, 9) util.check(http_resp.status == 200) http_resp_str = http_resp.read().decode('utf-8') util.debug(http_resp_str) util.check(http_resp_str.index('OK!') == 0)
def test_webserver(): util.log( """[START TEST] start container with enabled networking, run web server on priveledged port inside. Warning: stop network manager before running all network tests""" ) cont_ip = '192.168.1.1' cont_pid = aucont.start_daemonized( util.test_rootfs_path(), '/test/web/server.sh', '80', cont_ip=cont_ip ) time.sleep(2) url = 'http://' + cont_ip + ':80/file.txt' http_resp = urlopen(url) aucont.stop(cont_pid, 9) util.check(http_resp.status == 200) http_resp_str = http_resp.read().decode('utf-8') util.debug(http_resp_str) util.check(http_resp_str.index('OK!') == 0)
def test_many_conts_start_stop(): util.log("""[START_TEST] start 3 containers. Wait exiting of some of them. Stop all the containers manually.""") cont1_pid = aucont.start_daemonized(util.test_rootfs_path(), '/bin/sleep', '1') cont2_pid = aucont.start_daemonized(util.test_rootfs_path(), '/bin/sleep', '5') cont3_pid = aucont.start_daemonized(util.test_rootfs_path(), '/bin/sleep', '10') time.sleep(4) aucont.stop(cont3_pid, 9) aucont.stop(cont1_pid, 9) aucont.stop(cont2_pid, 9)
def test_many_conts_start_stop(): util.log("""[START_TEST] start 3 containers. Wait exiting of some of them. Stop all the containers manually.""") cont1_pid = aucont.start_daemonized( util.test_rootfs_path(), '/bin/sleep', '1' ) cont2_pid = aucont.start_daemonized( util.test_rootfs_path(), '/bin/sleep', '5' ) cont3_pid = aucont.start_daemonized( util.test_rootfs_path(), '/bin/sleep', '10' ) time.sleep(4) aucont.stop(cont3_pid, 9) aucont.stop(cont1_pid, 9) aucont.stop(cont2_pid, 9)