コード例 #1
0
def test_build_container(channel, img, gpu):
    assert docker.from_env().ping()
    # Make sure we accept all licenses,
    with TempDir() as tmp:
        args = Arguments(
            channel,
            img,
            tmp,
            None,
            False,
            "",
            gpu,
            True,
            False,
            False,
            "us-docker.pkg.dev/android-emulator-268719/images",
            False,
            False,
        )
        emu_docker.accept_licenses(args)
        devices = emu_docker.create_docker_image(args)
        assert devices
        for device in devices:
            assert device.image_name() is not None
            client = docker.from_env()
            assert client.images.get(device.full_name()) is not None
コード例 #2
0
def test_build_container(channel, img):
    assert docker.from_env().ping()
    with TempDir() as tmp:
        args = Arguments(channel, img, tmp, None, False, "")
        device = emu_docker.create_docker_image(args)
        assert device.identity is not None
        client = docker.from_env()
        assert client.images.get(device.identity) is not None
コード例 #3
0
def test_run_container(channel, img, gpu):
    with TempDir() as tmp:
        args = Arguments(
            channel,
            img,
            tmp,
            None,
            False,
            "",
            gpu,
            True,
            False,
            False,
            "us-docker.pkg.dev/android-emulator-268719/images",
            False,
            False,
        )
        emu_docker.accept_licenses(args)
        devices = emu_docker.create_docker_image(args)
        assert devices
        for device in devices:
            port = find_free_port()

            # Launch this thing.
            container = device.launch({"5555/tcp": port})
            # Now we are going to insepct this thing.
            api_client = device.get_api_client()
            status = api_client.inspect_container(container.id)
            state = status["State"]
            assert state["Status"] == "running"

            # Acceptable states:
            # starting --> We are still launching
            # healthy --> Yay, we booted! Good to go..
            health = state["Health"]["Status"]
            while health == "starting":
                health = api_client.inspect_container(
                    container.id)["State"]["Health"]["Status"]

            assert health == "healthy"

            # Good, good.. From an internal perspective things look great.
            # Can we connect with adb from outside the container?
            adb = find_adb()

            # Erase knowledge of existing devices.
            subprocess.check_output([adb, "kill-server"])
            name = "localhost:{}".format(port)
            subprocess.check_output([adb, "connect", name])

            # Boot complete should be true..
            res = subprocess.check_output(
                [adb, "-s", name, "shell", "getprop", "dev.bootcomplete"])
            assert "1" in str(res)

            api_client.stop(container.id)
コード例 #4
0
def test_build_container(channel, img, gpu):
    assert docker.from_env().ping()
    # Make sure we accept all licenses,
    with TempDir() as tmp:
        args = Arguments(channel, img, tmp, None, False, "", gpu, True, False,
                         False, "aemu", False)
        emu_docker.accept_licenses(args)
        device = emu_docker.create_docker_image(args)
        assert device.identity is not None
        client = docker.from_env()
        assert client.images.get(device.identity) is not None
コード例 #5
0
def test_run_container(channel, img):
    assert not "linux" in sys.platform
    assert docker.from_env().ping()
    with TempDir() as tmp:
        args = Arguments(channel, img, tmp, None, False, "")
        device = emu_docker.create_docker_image(args)
        port = find_free_port()

        # Launch this thing.
        device.launch(device.identity, port)
        # Now we are going to insepct this thing.
        api_client = device.get_api_client()
        status = api_client.inspect_container(device.container.id)
        state = status["State"]
        assert state["Status"] == "running"

        # Acceptable states:
        # starting --> We are still launching
        # healthy --> Yay, we booted! Good to go..
        health = state["Health"]["Status"]
        while health == "starting":
            health = api_client.inspect_container(
                device.container.id)["State"]["Health"]["Status"]

        assert health == "healthy"

        # Good, good.. From an internal perspective things look great.
        # Can we connect with adb from outside the container?
        adb = find_adb()

        # Erase knowledge of existing devices.
        subprocess.check_output([adb, "kill-server"])
        name = "localhost:{}".format(port)
        subprocess.check_output([adb, "connect", name])

        # Boot complete should be true..
        res = subprocess.check_output(
            [adb, "-s", name, "shell", "getprop", "dev.bootcomplete"])
        assert "1" in str(res)

        api_client.stop(device.container.id)