From e3b7a690eb5f9c372a7420372e6c1104488d2782 Mon Sep 17 00:00:00 2001 From: Andy Sadler Date: Wed, 11 Oct 2023 19:23:46 -0500 Subject: [PATCH] Ensure test-app deployments have unique labels per scenario (#74) Previously, since every deployment of the generic test app had the same label, the services we would make as a part of testing would forward requests to any running deployment since they could match the label selector. Make them unique, so that requests get forwarded to the correct pod. Signed-off-by: Andy Sadler --- features/steps/cluster.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/features/steps/cluster.py b/features/steps/cluster.py index cfb7246..5d2f85a 100644 --- a/features/steps/cluster.py +++ b/features/steps/cluster.py @@ -18,15 +18,15 @@ def __init__(self): name: '{name}' namespace: {namespace} labels: - app: myapp + app: '{name}' spec: selector: matchLabels: - app: myapp + app: '{name}' template: metadata: labels: - app: myapp + app: '{name}' spec: containers: - name: myapp @@ -196,8 +196,10 @@ def new_app(self, name, image_name, namespace, bindingRoot=None): namespace=namespace, bindingRoot=bindingRoot) if bindingRoot is not None: parsed = yaml.safe_load(formatted) - for obj in parsed['spec']['template']['spec']['containers']: - obj['env'] = [{'name': 'SERVICE_BINDING_ROOT', 'value': bindingRoot}] + for container in parsed['spec']['template']['spec']['containers']: + if 'env' not in container: + container['env'] = list() + container['env'].append({'name': 'SERVICE_BINDING_ROOT', 'value': bindingRoot}) formatted = yaml.dump(parsed) print(f'applying deployment: {formatted}') self.apply(formatted, namespace=namespace)