Ejemplo n.º 1
0
def test_ansible(base_image, init_system, ansible_version):
    if (base_image, init_system) in DEB_DISTROS:
        distro_type = "deb"
    else:
        distro_type = "rpm"
    buildargs = {"ANSIBLE_VERSION": ""}
    if ansible_version != "latest":
        buildargs = {"ANSIBLE_VERSION": f"=={ansible_version}"}
    opts = {
        "path": REPO_ROOT_DIR,
        "dockerfile": DOCKERFILES_DIR / f"Dockerfile.{base_image}",
        "buildargs": buildargs,
        "with_socat": False,
    }
    with run_init_system_image(base_image, **opts) as [cont, backend]:
        import_old_key(cont, distro_type)
        try:
            monitors = [{"type": "host-metadata"}]
            run_ansible(cont, init_system, backend, monitors, INITIAL_VERSION,
                        STAGE)
            assert wait_for(
                p(has_datapoint_with_dim, backend, "plugin",
                  "host-metadata")), "Datapoints didn't come through"

            assert_old_key_removed(cont, distro_type)

            if UPGRADE_VERSION:
                # upgrade agent
                run_ansible(cont,
                            init_system,
                            backend,
                            monitors,
                            UPGRADE_VERSION,
                            STAGE,
                            user="******")
                backend.reset_datapoints()
                assert wait_for(
                    p(has_datapoint_with_dim, backend, "plugin",
                      "host-metadata")), "Datapoints didn't come through"

                # downgrade agent
                run_ansible(cont, init_system, backend, monitors,
                            INITIAL_VERSION, STAGE)
                backend.reset_datapoints()
                assert wait_for(
                    p(has_datapoint_with_dim, backend, "plugin",
                      "host-metadata")), "Datapoints didn't come through"

            # change agent config
            monitors = [{"type": "internal-metrics"}]
            run_ansible(cont, init_system, backend, monitors, INITIAL_VERSION,
                        STAGE)
            backend.reset_datapoints()
            assert wait_for(
                p(has_datapoint_with_metric_name, backend,
                  "sfxagent.datapoints_sent")
            ), "Didn't get internal metric datapoints"
        finally:
            print("Agent log:")
            print_lines(get_agent_logs(cont, init_system))
Ejemplo n.º 2
0
def test_chef(base_image, init_system, chef_version):
    if (base_image, init_system) in DEB_DISTROS:
        distro_type = "deb"
    else:
        distro_type = "rpm"
    if base_image == "centos8" and chef_version != "latest" and int(
            chef_version.split(".")[0]) < 15:
        pytest.skip(f"chef {chef_version} not supported on centos 8")
    buildargs = {"CHEF_INSTALLER_ARGS": ""}
    if chef_version != "latest":
        buildargs["CHEF_INSTALLER_ARGS"] = f"-v {chef_version}"
    opts = {
        "path": REPO_ROOT_DIR,
        "dockerfile": DOCKERFILES_DIR / f"Dockerfile.{base_image}",
        "buildargs": buildargs
    }
    with run_init_system_image(base_image, **opts) as [cont, backend]:
        import_old_key(cont, distro_type)
        try:
            agent_version = INITIAL_VERSION
            monitors = [{"type": "host-metadata"}]
            run_chef_client(cont, chef_version, agent_version, STAGE, monitors)
            assert wait_for(
                p(has_datapoint_with_dim, backend, "plugin",
                  "host-metadata")), "Datapoints didn't come through"

            assert_old_key_removed(cont, distro_type)

            if UPGRADE_VERSION:
                # upgrade agent
                agent_version = UPGRADE_VERSION
                run_chef_client(cont, chef_version, agent_version, STAGE,
                                monitors)
                backend.reset_datapoints()
                assert wait_for(
                    p(has_datapoint_with_dim, backend, "plugin",
                      "host-metadata")), "Datapoints didn't come through"

                # downgrade agent for distros that support package downgrades
                if base_image not in ("debian-7-wheezy", "debian-8-jessie",
                                      "ubuntu1404"):
                    agent_version = INITIAL_VERSION
                    run_chef_client(cont, chef_version, agent_version, STAGE,
                                    monitors)
                    backend.reset_datapoints()
                    assert wait_for(
                        p(has_datapoint_with_dim, backend, "plugin",
                          "host-metadata")), "Datapoints didn't come through"

            # change agent config
            monitors = [{"type": "internal-metrics"}]
            run_chef_client(cont, chef_version, agent_version, STAGE, monitors)
            backend.reset_datapoints()
            assert wait_for(
                p(has_datapoint_with_metric_name, backend,
                  "sfxagent.datapoints_sent")
            ), "Didn't get internal metric datapoints"
        finally:
            print("Agent log:")
            print_lines(get_agent_logs(cont, init_system))
Ejemplo n.º 3
0
def test_puppet(base_image, init_system, puppet_release):
    if (base_image, init_system) in DEB_DISTROS:
        distro_type = "deb"
    else:
        distro_type = "rpm"
    buildargs = {"PUPPET_RELEASE": ""}
    if puppet_release != "latest":
        buildargs = {"PUPPET_RELEASE": puppet_release}
    opts = {
        "path": REPO_ROOT_DIR,
        "dockerfile": DOCKERFILES_DIR / f"Dockerfile.{base_image}",
        "buildargs": buildargs,
        "with_socat": False,
    }
    with run_init_system_image(base_image, **opts) as [cont, backend]:
        import_old_key(cont, distro_type)
        if (base_image, init_system) in DEB_DISTROS:
            code, output = cont.exec_run(
                f"puppet module install puppetlabs-apt --version {APT_MODULE_VERSION}"
            )
            assert code == 0, output.decode("utf-8")
            print_lines(output)
        try:
            monitors = [{"type": "host-metadata"}]
            run_puppet_agent(cont, backend, monitors, INITIAL_VERSION, STAGE)
            assert wait_for(
                p(has_datapoint_with_dim, backend, "plugin",
                  "host-metadata")), "Datapoints didn't come through"

            assert_old_key_removed(cont, distro_type)

            if UPGRADE_VERSION:
                # upgrade agent
                run_puppet_agent(cont, backend, monitors, UPGRADE_VERSION,
                                 STAGE)
                backend.reset_datapoints()
                assert wait_for(
                    p(has_datapoint_with_dim, backend, "plugin",
                      "host-metadata")), "Datapoints didn't come through"

                # downgrade agent
                run_puppet_agent(cont, backend, monitors, INITIAL_VERSION,
                                 STAGE)
                backend.reset_datapoints()
                assert wait_for(
                    p(has_datapoint_with_dim, backend, "plugin",
                      "host-metadata")), "Datapoints didn't come through"

            # change agent config
            monitors = [{"type": "internal-metrics"}]
            run_puppet_agent(cont, backend, monitors, INITIAL_VERSION, STAGE)
            backend.reset_datapoints()
            assert wait_for(
                p(has_datapoint_with_metric_name, backend,
                  "sfxagent.datapoints_sent")
            ), "Didn't get internal metric datapoints"
        finally:
            print("Agent log:")
            print_lines(get_agent_logs(cont, init_system))
Ejemplo n.º 4
0
def test_salt(base_image, init_system):
    if (base_image, init_system) in DEB_DISTROS:
        distro_type = "deb"
    else:
        distro_type = "rpm"

    opts = {"path": REPO_ROOT_DIR, "dockerfile": DOCKERFILES_DIR / f"Dockerfile.{base_image}", "with_socat": False}
    with run_init_system_image(base_image, **opts) as [cont, backend]:
        try:
            import_old_key(cont, distro_type)

            monitors = [{"type": "host-metadata"}]
            run_salt(cont, init_system, backend, INITIAL_VERSION, monitors, STAGE)
            assert wait_for(
                p(has_datapoint_with_dim, backend, "plugin", "host-metadata")
            ), "Datapoints didn't come through"

            assert_old_key_removed(cont, distro_type)

            if UPGRADE_VERSION:
                # upgrade agent
                user = "******"
                if tuple(UPGRADE_VERSION.split(".")) >= ("5", "1", "0"):
                    user = "******"
                run_salt(cont, init_system, backend, UPGRADE_VERSION, monitors, STAGE, user)
                backend.reset_datapoints()
                assert wait_for(
                    p(has_datapoint_with_dim, backend, "plugin", "host-metadata")
                ), "Datapoints didn't come through"

                # downgrade agent
                run_salt(cont, init_system, backend, INITIAL_VERSION, monitors, STAGE)
                backend.reset_datapoints()
                assert wait_for(
                    p(has_datapoint_with_dim, backend, "plugin", "host-metadata")
                ), "Datapoints didn't come through"

            # change agent config
            monitors = [{"type": "internal-metrics"}]
            run_salt(cont, init_system, backend, INITIAL_VERSION, monitors, STAGE)
            backend.reset_datapoints()
            assert wait_for(
                p(has_datapoint_with_metric_name, backend, "sfxagent.datapoints_sent")
            ), "Didn't get internal metric datapoints"

        finally:
            print("Agent log:")
            print_lines(get_agent_logs(cont, init_system))