def test_helm_values_try_set_by_list_index(): helm_values = HelmValues(BASE_HELM_VALUES) try: helm_values.set("nested_list[0]", 4) except ValueError: return assert False, "expected 'ValueError' exception was not raised"
def test_helm_values_set_nested_override(): helm_values = HelmValues(BASE_HELM_VALUES) helm_values.set("nested_dict.first_nested_dict_key", "new_value") data = helm_values.as_dict() assert "nested_dict" in data assert "first_nested_dict_key" in data["nested_dict"] assert data["nested_dict"]["first_nested_dict_key"] == "new_value"
def test_helm_values_set_nested_new(): helm_values = HelmValues(BASE_HELM_VALUES) helm_values.set("nested_dict.third_nested_dict_key", "third_nested_dict_value") data = helm_values.as_dict() assert "nested_dict" in data assert "third_nested_dict_key" in data["nested_dict"] assert data["nested_dict"][ "third_nested_dict_key"] == "third_nested_dict_value" assert "first_nested_dict_key" in data["nested_dict"] assert data["nested_dict"][ "first_nested_dict_key"] == "first_nested_dict_value" assert "second_nested_dict_key" in data["nested_dict"] assert data["nested_dict"][ "second_nested_dict_key"] == "second_nested_dict_value"
def reinstall_scylla_manager(db_cluster: ScyllaPodCluster, manager_version: str): values = HelmValues( yaml.safe_load( db_cluster.k8s_cluster.helm("get values scylla-manager -o yaml", namespace=SCYLLA_MANAGER_NAMESPACE))) if values.get("image.tag") != manager_version: log.info( "Scylla Manager '%s' is going to be installed instead of the '%s' one.", manager_version, values.get("image.tag")) values.set('image.tag', manager_version) values.set('scylla.agentImage.tag', manager_version) # Delete the current scylla-manager completely because otherwise # we won't be able to migrate DB state from a newer version to older one. db_cluster.k8s_cluster.helm("uninstall scylla-manager --wait", namespace=SCYLLA_MANAGER_NAMESPACE) wait_for_resource_absence(db_cluster=db_cluster, step=1, timeout=120, resource_name="", resource_type="pod", namespace=SCYLLA_MANAGER_NAMESPACE) db_cluster.k8s_cluster.kubectl("delete pvc --all --wait=true", namespace=SCYLLA_MANAGER_NAMESPACE) # Deploy Scylla Manager of the specified version log.debug( db_cluster.k8s_cluster.helm_install( target_chart_name="scylla-manager", source_chart_name="scylla-operator/scylla-manager", version=db_cluster.k8s_cluster._scylla_operator_chart_version, # pylint: disable=protected-access use_devel=True, values=values, namespace=SCYLLA_MANAGER_NAMESPACE, )) time.sleep(5) db_cluster.k8s_cluster.kubectl_wait("--all --for=condition=Ready pod", namespace=SCYLLA_MANAGER_NAMESPACE, timeout=600) log.info("Scylla Manager '%s' has successfully been installed", manager_version)
def test_helm_values_set_override(): helm_values = HelmValues(BASE_HELM_VALUES) helm_values.set("no_nesting_key", "custom_value") assert helm_values.get("no_nesting_key") == "custom_value"
def test_helm_values_set_new(): helm_values = HelmValues(BASE_HELM_VALUES) helm_values.set("new_key", "new_value") assert helm_values.get("new_key") == "new_value"