Skip to content

Commit

Permalink
Ensure test-app deployments have unique labels per scenario (#74)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sadlerap authored Oct 12, 2023
1 parent 0dadd69 commit e3b7a69
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions features/steps/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e3b7a69

Please sign in to comment.