Exemple #1
0
def test_many_cont_networks():
    util.log(
        """[START TEST] start 2 containers run simple networking
        tests in each one.
        Warning: stop network manager before running all
        network tests"""
    )
    cont1_ip = '192.168.1.1'
    host1_ip = '192.168.1.2'
    cont1_pid = aucont.start_daemonized(
        util.test_rootfs_path(), '/bin/sleep', '10000',
        cont_ip=cont1_ip
    )
    
    cont2_ip = '10.0.0.1'
    host2_ip = '10.0.0.2'
    cont2_pid = aucont.start_daemonized(
        util.test_rootfs_path(), '/bin/sleep', '10000',
        cont_ip=cont2_ip
    )

    time.sleep(2)

    aucont.exec_capture_output(cont1_pid, '/test/net/test.sh',
        cont1_ip, host1_ip
    )
    aucont.exec_capture_output(cont1_pid, '/test/net/test.sh',
        cont1_ip, host1_ip
    )

    cleanup()
Exemple #2
0
def test_many_cont_networks():
    util.log("""[START TEST] start 2 containers run simple networking
        tests in each one.
        Warning: stop network manager before running all
        network tests""")
    cont1_ip = '192.168.1.1'
    host1_ip = '192.168.1.2'
    cont1_pid = aucont.start_daemonized(util.test_rootfs_path(),
                                        '/bin/sleep',
                                        '10000',
                                        cont_ip=cont1_ip)

    cont2_ip = '10.0.0.1'
    host2_ip = '10.0.0.2'
    cont2_pid = aucont.start_daemonized(util.test_rootfs_path(),
                                        '/bin/sleep',
                                        '10000',
                                        cont_ip=cont2_ip)

    time.sleep(2)

    aucont.exec_capture_output(cont1_pid, '/test/net/test.sh', cont1_ip,
                               host1_ip)
    aucont.exec_capture_output(cont1_pid, '/test/net/test.sh', cont1_ip,
                               host1_ip)

    cleanup()
Exemple #3
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)
Exemple #4
0
def test_many_cont_list():
    util.log("""[START_TEST] start 3 containers.
        Check that aucont_list tool returns right
        values.""")
    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')
    cont_list = aucont.clist()
    util.check(len(cont_list) == 3)
    cont_list.index(cont1_pid)
    cont_list.index(cont2_pid)
    cont_list.index(cont3_pid)
    cleanup()
Exemple #5
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)
Exemple #6
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)
Exemple #7
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)
Exemple #8
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)
Exemple #9
0
def test_many_cont_list():
    util.log("""[START_TEST] start 3 containers.
        Check that aucont_list tool returns right
        values.""")
    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'
    )
    cont_list = aucont.clist()
    util.check(len(cont_list) == 3)
    cont_list.index(cont1_pid)
    cont_list.index(cont2_pid)
    cont_list.index(cont3_pid)
    cleanup()
Exemple #10
0
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')
Exemple #11
0
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')
Exemple #12
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)
Exemple #13
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)