コード例 #1
0
    def test_artifacts_exclusive_to_user(self):
        users = [
            {
                "email": "*****@*****.**",
                "password": "******",
                "username": "******"
            },
            {
                "email": "*****@*****.**",
                "password": "******",
                "username": "******"
            },
        ]

        for user in users:
            auth.set_tenant(user["username"], user["email"], user["password"])
            with artifact_lock:
                with tempfile.NamedTemporaryFile() as artifact_file:
                    artifact = image.make_artifact(conftest.get_valid_image(),
                                                   conftest.machine_name,
                                                   user["email"],
                                                   artifact_file)

                    deploy.upload_image(artifact)

        for user in users:
            auth.set_tenant(user["username"], user["email"], user["password"])
            artifacts_for_user = deploy.get_artifacts()

            # make sure that one a single artifact exist for a given tenant
            assert len(artifacts_for_user)
            assert artifacts_for_user[0]["name"] == user["email"]
コード例 #2
0
def common_update_proceduce(install_image,
                            regnerate_image_id=True,
                            device_type="vexpress-qemu",
                            checksum="abc123",
                            broken_image=False):

    if broken_image:
        artifact_id = "broken_image_" + str(random.randint(0, 999999))
    elif regnerate_image_id:
        artifact_id = Helpers.artifact_id_randomize(install_image)
        logger.debug("Randomized image id: " + artifact_id)
    else:
        artifact_id = Helpers.yocto_id_from_ext4(install_image)

    # create atrifact
    artifact_file = "artifact.mender"
    created = image.make_artifact(install_image, device_type, artifact_id,
                                  artifact_file)

    if created:
        deploy.upload_image("artifact.mender")
        devices_accepted_id = [
            device["id"] for device in adm.get_devices_status("accepted")
        ]
        deployment_id = deploy.trigger_deployment(name="New valid update",
                                                  artifact_name=artifact_id,
                                                  devices=devices_accepted_id)

        # remove the artifact file
        os.remove(artifact_file)
        return deployment_id, artifact_id

    logger.error("error creating artifact")
コード例 #3
0
def common_update_procedure(install_image,
                            regenerate_image_id=True,
                            device_type=conftest.machine_name,
                            broken_image=False,
                            verify_status=True,
                            signed=False,
                            devices=None,
                            scripts=[],
                            pre_upload_callback=lambda: None,
                            pre_deployment_callback=lambda: None,
                            deployment_triggered_callback=lambda: None,
                            compression_type="gzip"):

    with artifact_lock:
        if broken_image:
            artifact_id = "broken_image_" + str(random.randint(0, 999999))
        elif regenerate_image_id:
            artifact_id = Helpers.artifact_id_randomize(install_image)
            logger.debug("randomized image id: " + artifact_id)
        else:
            artifact_id = Helpers.yocto_id_from_ext4(install_image)

        compression_arg = "--compression " + compression_type

        # create atrifact
        with tempfile.NamedTemporaryFile() as artifact_file:
            created_artifact = image.make_artifact(
                install_image,
                device_type,
                artifact_id,
                artifact_file,
                signed=signed,
                scripts=scripts,
                global_flags=compression_arg)

            if created_artifact:
                pre_upload_callback()
                deploy.upload_image(created_artifact)
                if devices is None:
                    devices = list(
                        set([
                            device["device_id"]
                            for device in adm.get_devices_status("accepted")
                        ]))
                pre_deployment_callback()
                deployment_id = deploy.trigger_deployment(
                    name="New valid update",
                    artifact_name=artifact_id,
                    devices=devices)
            else:
                logger.warn("failed to create artifact")
                pytest.fail("error creating artifact")

    deployment_triggered_callback()
    # wait until deployment is in correct state
    if verify_status:
        deploy.check_expected_status("inprogress", deployment_id)

    return deployment_id, artifact_id
コード例 #4
0
def common_update_procedure(install_image,
                            regenerate_image_id=True,
                            device_type="vexpress-qemu",
                            broken_image=False,
                            verify_status=True,
                            devices=None):

    with artifact_lock:
        if broken_image:
            artifact_id = "broken_image_" + str(random.randint(0, 999999))
        elif regenerate_image_id:
            artifact_id = Helpers.artifact_id_randomize(install_image)
            logger.debug("Randomized image id: " + artifact_id)
        else:
            artifact_id = Helpers.yocto_id_from_ext4(install_image)

        # create atrifact
        with tempfile.NamedTemporaryFile() as artifact_file:
            created_artifact = image.make_artifact(install_image, device_type,
                                                   artifact_id, artifact_file)

            if created_artifact:
                deploy.upload_image(created_artifact)
                if devices is None:
                    devices = list(
                        set([
                            device["device_id"]
                            for device in adm.get_devices_status("accepted")
                        ]))
                deployment_id = deploy.trigger_deployment(
                    name="New valid update",
                    artifact_name=artifact_id,
                    devices=devices)
            else:
                pytest.fail("error creating artifact")

        # wait until deployment is in correct state
        if verify_status:
            deploy.check_expected_status("inprogress", deployment_id)

        return deployment_id, artifact_id