示例#1
0
def run_win_chef_setup(chef_version):
    assert has_choco(), "choco not installed!"
    uninstall_win_agent()
    if run_win_command("chef-client --version", []).returncode == 0:
        run_win_command("choco uninstall -y -f chef-client")
    if chef_version == "latest":
        run_win_command(f"choco upgrade -y -f chef-client")
    else:
        run_win_command(
            f"choco upgrade -y -f chef-client --version {chef_version}")
    if WIN_CHEF_BIN_DIR not in os.environ.get("PATH"):
        os.environ["PATH"] = WIN_CHEF_BIN_DIR + ";" + os.environ.get("PATH")
    if WIN_GEM_BIN_DIR not in os.environ.get("PATH"):
        os.environ["PATH"] = WIN_GEM_BIN_DIR + ";" + os.environ.get("PATH")
    os.makedirs(WIN_CHEF_COOKBOOKS_DIR, exist_ok=True)
    if os.path.isdir(WIN_AGENT_COOKBOOK_DEST_DIR):
        shutil.rmtree(WIN_AGENT_COOKBOOK_DEST_DIR)
    shutil.copytree(WIN_AGENT_COOKBOOK_SRC_DIR, WIN_AGENT_COOKBOOK_DEST_DIR)
    if not os.path.isdir(WINDOWS_COOKBOOK_DIR):
        run_win_command(
            f'powershell -command "curl -outfile windows.tar.gz {WINDOWS_COOKBOOK_URL}"',
            cwd=WIN_CHEF_COOKBOOKS_DIR)
        run_win_command('powershell -command "tar -zxvf windows.tar.gz"',
                        cwd=WIN_CHEF_COOKBOOKS_DIR)
    run_win_command(
        f'powershell -command "gem install rubyzip -q -v "{RUBYZIP_VERSION}""')
示例#2
0
def test_win_local_nupkg(request):
    assert has_choco(), "choco not installed"

    # Get nupkg path from command line flag to pytest
    nupkg_path = request.config.getoption("--test-nupkg-path")
    if not nupkg_path:
        raise ValueError(
            "You must specify the --test-nupkg-path flag to run choco tests")

    nupkg_path = os.path.abspath(nupkg_path)
    assert os.path.isfile(nupkg_path), f"{nupkg_path} not found!"

    nupkg_dir = os.path.dirname(nupkg_path)

    uninstall_win_agent()

    with ensure_fake_backend() as backend:
        try:
            params = f"/access_token:MYTOKEN /ingest_url:{backend.ingest_url} /api_url:{backend.api_url}"
            run_win_command(
                f"choco install signalfx-agent -y -s {nupkg_dir} --params=\"'{params}'\""
            )
            assert wait_for(
                p(has_datapoint_with_dim, backend, "plugin",
                  "host-metadata")), "Datapoints didn't come through"
        finally:
            print("\nDatapoints received:")
            for dp in backend.datapoints:
                print_dp_or_event(dp)
            print("\nEvents received:")
            for event in backend.events:
                print_dp_or_event(event)
            print(f"\nDimensions set: {backend.dims}")
            run_win_command("choco uninstall -y signalfx-agent")
            uninstall_win_agent()
示例#3
0
def run_win_puppet_setup(puppet_version):
    assert has_choco(), "choco not installed!"
    uninstall_win_agent()
    if puppet_version == "latest":
        run_win_command(f"choco upgrade -y -f puppet-agent")
    else:
        run_win_command(f"choco upgrade -y -f puppet-agent --version {puppet_version}")
    if WIN_PUPPET_BIN_DIR not in os.environ.get("PATH"):
        os.environ["PATH"] = WIN_PUPPET_BIN_DIR + ";" + os.environ.get("PATH")
    if os.path.isdir(WIN_PUPPET_MODULE_DEST_DIR):
        shutil.rmtree(WIN_PUPPET_MODULE_DEST_DIR)
    shutil.copytree(WIN_PUPPET_MODULE_SRC_DIR, WIN_PUPPET_MODULE_DEST_DIR)
    run_win_command("puppet module install puppet-archive")
    run_win_command("puppet module install puppetlabs-powershell")