Skip to content

Commit

Permalink
tests: Update all substitution variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Nov 9, 2023
1 parent 941927d commit c800eb7
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 34 deletions.
4 changes: 2 additions & 2 deletions examples/bakdata/atm-fraud-detection/config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
environment: development

topic_name_config:
default_error_topic_name: "${pipeline_name}-${component_name}-dead-letter-topic"
default_output_topic_name: "${pipeline_name}-${component_name}-topic"
default_error_topic_name: "${pipeline_name}-${component__name}-dead-letter-topic"
default_output_topic_name: "${pipeline_name}-${component__name}-topic"

kafka_brokers: "http://k8kafka-cp-kafka-headless.kpops.svc.cluster.local:9092"

Expand Down
2 changes: 1 addition & 1 deletion examples/bakdata/atm-fraud-detection/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ kafka-app:
app:
streams:
brokers: ${kafka_brokers}
schemaRegistryUrl: ${schema_registry_url}
schemaRegistryUrl: ${schema_registry__url}
optimizeLeaveGroupBehavior: false

producer-app:
Expand Down
4 changes: 2 additions & 2 deletions kpops/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class TopicNameConfig(BaseSettings):
"""Configure the topic name variables you can use in the pipeline definition."""

default_output_topic_name: str = Field(
default="${pipeline_name}-${component_name}",
default="${pipeline_name}-${component__name}",
description="Configures the value for the variable ${output_topic_name}",
)
default_error_topic_name: str = Field(
default="${pipeline_name}-${component_name}-error",
default="${pipeline_name}-${component__name}-error",
description="Configures the value for the variable ${error_topic_name}",
)

Expand Down
3 changes: 2 additions & 1 deletion kpops/pipeline_generator/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,10 @@ def substitute_in_component(self, component_as_dict: dict) -> dict:
component_as_dict,
"component",
substitution_hardcoded,
separator="__",
)
substitution = generate_substitution(
config.model_dump(mode="json"), existing_substitution=component_substitution
config.model_dump(mode="json"), existing_substitution=component_substitution, separator="__"
)

return json.loads(
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/test_kpops_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def test_kpops_config_with_default_values():
assert default_config.defaults_filename_prefix == "defaults"
assert (
default_config.topic_name_config.default_output_topic_name
== "${pipeline_name}-${component_name}"
== "${pipeline_name}-${component__name}"
)
assert (
default_config.topic_name_config.default_error_topic_name
== "${pipeline_name}-${component_name}-error"
== "${pipeline_name}-${component__name}-error"
)
assert default_config.schema_registry.enabled is False
assert default_config.schema_registry.url == AnyHttpUrl("http://localhost:8081")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- type: converter
app:
labels:
l_1: ${component_app_labels_l_2}
l_2: ${component_app_labels_l_1}
infinite_nesting: ${component_app_labels}
l_1: ${component__app__labels__l_2}
l_2: ${component__app__labels__l_1}
infinite_nesting: ${component__app__labels}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- type: scheduled-producer
app:
labels:
app_type: "${component_type}"
app_name: "${component_name}"
app_schedule: "${component_app_schedule}"
app_type: "${component__type}"
app_name: "${component__name}"
app_schedule: "${component__app__schedule}"
commandLine:
FAKE_ARG: "fake-arg-value"
schedule: "30 3/8 * * *"
Expand All @@ -20,11 +20,11 @@
name: "filter-app"
app:
labels:
app_type: "${component_type}"
app_name: "${component_name}"
app_resources_requests_memory: "${component_app_resources_requests_memory}"
${component_type}: "${component_app_labels_app_name}-${component_app_labels_app_type}"
test_placeholder_in_placeholder: "${component_app_labels_${component_type}}"
app_type: "${component__type}"
app_name: "${component__name}"
app_resources_requests_memory: "${component__app__resources__requests__memory}"
${component__type}: "${component__app__labels__app_name}-${component__app__labels__app_type}"
test_placeholder_in_placeholder: "${component__app__labels__${component__type}}"
commandLine:
TYPE: "nothing"
resources:
Expand Down
4 changes: 2 additions & 2 deletions tests/pipeline/resources/custom-config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
environment: development
defaults_path: ../no-topics-defaults
topic_name_config:
default_error_topic_name: "${component_name}-dead-letter-topic"
default_output_topic_name: "${component_name}-test-topic"
default_error_topic_name: "${component__name}-dead-letter-topic"
default_output_topic_name: "${component__name}-test-topic"
kafka_brokers: "http://k8kafka-cp-kafka-headless.kpops.svc.cluster.local:9092"
kafka_connect:
url: "http://localhost:8083"
Expand Down
4 changes: 2 additions & 2 deletions tests/pipeline/resources/defaults.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kubernetes-app:
name: "${component_type}"
name: "${component__type}"
namespace: example-namespace

kafka-app:
app:
streams:
brokers: "${kafka_brokers}"
schema_registry_url: "${schema_registry_url}"
schema_registry_url: "${schema_registry__url}"
version: "2.4.2"

producer-app: {} # inherits from kafka-app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ environment: development
defaults_path: ..
kafka_brokers: "broker:9092"
topic_name_config:
default_error_topic_name: ${component_type}-error-topic
default_output_topic_name: ${component_type}-output-topic
default_error_topic_name: ${component__type}-error-topic
default_output_topic_name: ${component__type}-output-topic
helm_diff_config:
enable: false
kafka_connect:
Expand Down
2 changes: 1 addition & 1 deletion tests/pipeline/resources/no-topics-defaults/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kafka-app:
app:
streams:
brokers: "${kafka_brokers}"
schemaRegistryUrl: "${schema_registry_url}"
schemaRegistryUrl: "${schema_registry__url}"

producer-app:
to:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kubernetes-app:
name: "${component_type}-development"
name: "${component__type}-development"
namespace: development-namespace
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ kafka-app:
app:
streams:
brokers: ${kafka_brokers}
schemaRegistryUrl: ${schema_registry_url}
schemaRegistryUrl: ${schema_registry__url}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
kubernetes-app:
name: ${component_type}
name: ${component__type}
namespace: example-namespace
kafka-app:
app:
streams:
brokers: "${kafka_brokers}"
schemaRegistryUrl: "${schema_registry_url}"
schemaRegistryUrl: "${schema_registry__url}"

producer-app: {} # inherits from kafka-app

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kubernetes-app:
name: ${component_type}-development
name: ${component__type}-development
namespace: development-namespace
6 changes: 3 additions & 3 deletions tests/pipeline/test_components/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def inflate(self) -> list[PipelineComponent]:
},
to=ToSection(
topics={
TopicName("${component_type}"): TopicConfig(
TopicName("${component__type}"): TopicConfig(
type=OutputTopicTypes.OUTPUT
),
TopicName("${component_name}"): TopicConfig(
TopicName("${component__name}"): TopicConfig(
type=None, role="test"
),
}
Expand All @@ -68,7 +68,7 @@ def inflate(self) -> list[PipelineComponent]:
to=ToSection( # type: ignore[reportGeneralTypeIssues]
topics={
TopicName(
f"{self.full_name}-" + "${component_name}"
f"{self.full_name}-" + "${component__name}"
): TopicConfig(type=OutputTopicTypes.OUTPUT)
}
).model_dump(),
Expand Down

0 comments on commit c800eb7

Please sign in to comment.