Exemple #1
0
def test_chart_installation(config_map):
    builder = ChartBuilder(
        ChartInfo(
            api_version="3.2.4",
            name="test",
            version="0.1.0",
            app_version="v1",
            maintainers=[
                ChartMaintainer("A Name Jr.", "*****@*****.**",
                                "www.example.com")
            ],
        ),
        [config_map],
    )
    assert not builder.is_installed
    with ChartInstallationContext(builder):
        # Check helm release
        helm_installation = get_helm_installations()
        assert helm_installation["NAME"][0] == "test"
        assert helm_installation["REVISION"][0] == "1"
        assert helm_installation["STATUS"][0] == "deployed"

        assert builder.is_installed

        config_maps = kubectl_get("configmaps")
        assert config_maps["NAME"][0] == "test-config-map"
        assert config_maps["DATA"][0] == "1"
Exemple #2
0
def test_installation_with_namespace(chart_info):
    builder = ChartBuilder(chart_info, [], namespace="test")
    with ChartInstallationContext(builder, timeout=60):
        # Check helm release
        helm_installation = get_helm_installations("test")
        assert helm_installation["NAME"][0] == "test"
        assert helm_installation["REVISION"][0] == "1"
        assert helm_installation["STATUS"][0] == "deployed"
        assert helm_installation["NAMESPACE"][0] == "test"
Exemple #3
0
def test_installation_with_value_args(chart_info):
    builder = ChartBuilder(chart_info, [], namespace="test")
    with ChartInstallationContext(builder,
                                  extra_installation_args={"output": "json"}):
        helm_installation = get_helm_installations("test")
        assert helm_installation["NAME"][0] == "test"
        assert helm_installation["REVISION"][0] == "1"
        assert helm_installation["STATUS"][0] == "deployed"
        assert helm_installation["NAMESPACE"][0] == "test"
Exemple #4
0
def test_helm_upgrade(chart_info):
    builder = ChartBuilder(chart_info, [])
    with ChartInstallationContext(builder):
        # Check helm release
        builder.upgrade_chart()
        helm_installation = get_helm_installations()
        assert helm_installation["NAME"][0] == "test"
        assert helm_installation["REVISION"][0] == "2"
        assert helm_installation["STATUS"][0] == "deployed"
        assert helm_installation["NAMESPACE"][0] == "default"
Exemple #5
0
def test_chart_w_dependencies(grafana_dependency, dependency_chart_info):
    builder = ChartBuilder(dependency_chart_info, [])
    with ChartInstallationContext(builder, timeout=60):
        # Check helm release
        helm_installation = get_helm_installations()
        assert helm_installation["NAME"][0] == "test"
        assert helm_installation["REVISION"][0] == "1"
        assert helm_installation["STATUS"][0] == "deployed"

        assert builder.is_installed

    # Test reinstalling the same helm chart / repo
    with ChartInstallationContext(builder, timeout=60):
        assert builder.is_installed

    remove_stable_repo()
Exemple #6
0
def test_helm_upgrade_w_dependencies(chart_info, grafana_dependency):
    builder = ChartBuilder(
        ChartInfo(
            api_version="3.2.4",
            name="test",
            version="0.1.0",
            app_version="v1",
            dependencies=[grafana_dependency],
        ),
        [],
    )
    with ChartInstallationContext(builder):
        builder.upgrade_chart(options={"dependency-update": None})
        helm_installation = get_helm_installations()
        assert helm_installation["NAME"][0] == "test"
        assert helm_installation["REVISION"][0] == "2"
        assert helm_installation["STATUS"][0] == "deployed"
        assert helm_installation["NAMESPACE"][0] == "default"

    remove_stable_repo()
Exemple #7
0
def test_installing_two_components(
    config_map,
    config_map2,
    chart_info: ChartInfo,
):
    config_map.metadata.name = "test-config-map-1"
    builder = ChartBuilder(
        chart_info,
        [config_map, config_map2],
    )
    with ChartInstallationContext(builder):
        # Check helm release
        helm_installation = get_helm_installations()
        assert helm_installation["NAME"][0] == "test"
        assert helm_installation["REVISION"][0] == "1"
        assert helm_installation["STATUS"][0] == "deployed"

        # Check kubernetes components
        config_maps = kubectl_get("configmaps")
        for i in range(2):
            assert config_maps["NAME"][i] == f"test-config-map-{i + 1}"
            assert config_maps["DATA"][i] == "1"