Skip to content

Commit

Permalink
Merge pull request #1 from RoseTeague/backlog-939
Browse files Browse the repository at this point in the history
feat: add custom template labels
  • Loading branch information
roseteague authored Mar 1, 2019
2 parents fd16f2e + 48f104d commit 210808b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
6 changes: 4 additions & 2 deletions kubee2etests/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ class Deployment(ApiMixin):
def __init__(self, name, namespace, replicas=e2e_globals.TEST_REPLICAS,
cfgmap_name=e2e_globals.TEST_INDEX_NAME,
labels=e2e_globals.TEST_LABELS,
template_labels=e2e_globals.TEST_TEMPLATE_LABELS,
vol_claim=None):
super().__init__(namespace=namespace)
self.name = name
self.replicas = replicas
self.cfgmap_name = cfgmap_name
self.labels = labels
self.template_labels = template_labels
self.vol_claim_name = vol_claim
# Api used for deployment methods. Core api used for any pod methods
self.extensions_api = client.ExtensionsV1beta1Api()
Expand All @@ -32,7 +34,7 @@ def __init__(self, name, namespace, replicas=e2e_globals.TEST_REPLICAS,

@property
def label_selector(self):
return ",".join(["%s=%s" % (key, value) for key, value in self.labels.items()])
return ",".join(["%s=%s" % (key, value) for key, value in self.template_labels.items()])

@property
def k8s_object(self):
Expand All @@ -50,7 +52,7 @@ def k8s_object(self):
),
template=client.V1PodTemplateSpec(
metadata=client.V1ObjectMeta(
labels=self.labels),
labels=self.template_labels),
spec=client.V1PodSpec(
affinity=client.V1Affinity(
pod_anti_affinity=client.V1PodAntiAffinity(
Expand Down
3 changes: 3 additions & 0 deletions kubee2etests/helpers_and_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@

TEST_REPLICAS = 3
CUSTOM_LABELS = ast.literal_eval(os.environ.get("CUSTOM_TEST_DEPLOYMENT_LABELS", '{}'))
CUSTOM_TEMPLATE_LABELS = ast.literal_eval(os.environ.get("CUSTOM_TEST_DEPLOYMENT_TEMPLATE_LABELS", '{}'))
TEST_LABELS = {'app': 'hellominikube'}
TEST_LABELS.update(CUSTOM_LABELS)
TEST_TEMPLATE_LABELS = {'app': 'hellominikube'}
TEST_TEMPLATE_LABELS.update(CUSTOM_TEMPLATE_LABELS)
TEST_CONTAINER_PORT = 80

# time to wait for events before timing out, used in wait_on_event
Expand Down
4 changes: 3 additions & 1 deletion kubee2etests/runners/deployment_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def __init__(self, deployment=e2e_globals.TEST_DEPLOYMENT, namespace=e2e_globals
replicas=e2e_globals.TEST_REPLICAS, cfgmap_name=e2e_globals.TEST_INDEX_NAME,
cfgmap_index=e2e_globals.TEST_DEPLOYMENT_INDEX,
labels=e2e_globals.TEST_LABELS,
template_labels=e2e_globals.TEST_TEMPLATE_LABELS,
volume_claim=None,
claim_storage=None,
**kwargs):
Expand All @@ -18,7 +19,8 @@ def __init__(self, deployment=e2e_globals.TEST_DEPLOYMENT, namespace=e2e_globals
namespace,
replicas,
cfgmap_name,
labels)
labels,
template_labels)
self.cfgmap = ConfigMap(name=cfgmap_name,
index=cfgmap_index,
namespace=namespace)
Expand Down
4 changes: 3 additions & 1 deletion kubee2etests/runners/runnerbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ def __init__(self, namespace,
deployment,
replicas=e2e_globals.TEST_REPLICAS,
labels=e2e_globals.TEST_LABELS,
template_labels=e2e_globals.TEST_TEMPLATE_LABELS,
cfgmap=e2e_globals.TEST_INDEX_NAME, **kwargs):
super().__init__(namespace)
self.labels = labels
self.deployment = Deployment(deployment, namespace, replicas, cfgmap, labels)
self.template_labels = template_labels
self.deployment = Deployment(deployment, namespace, replicas, cfgmap, labels, template_labels)
self.cfgmap = ConfigMap(name=cfgmap,
index=TEST_DEPLOYMENT_INDEX,
namespace=self.namespace)
Expand Down
2 changes: 1 addition & 1 deletion kubee2etests/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def k8s_object(self):
spec=client.V1ServiceSpec(ports=[
client.V1ServicePort(port=10, target_port=e2e_globals.TEST_CONTAINER_PORT),
],
selector=e2e_globals.TEST_LABELS)
selector=e2e_globals.TEST_TEMPLATE_LABELS)
)

def _read_from_k8s(self, should_exist=True):
Expand Down

0 comments on commit 210808b

Please sign in to comment.