Skip to content

Commit 401644e

Browse files
committed
test(test_deployments.py): add tests for spec_annotations of deployments and pods
Adding some tests to make sure spec_annotations are propagating to future releases and child pods after being set.
1 parent e95ede0 commit 401644e

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

rootfs/scheduler/tests/test_deployments.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,51 @@ def test_get_deployment_replicaset(self):
243243
data
244244
)
245245

246+
def test_get_deployment_annotations(self):
247+
"""
248+
Look at the annotations on the Deployment object
249+
"""
250+
# test success
251+
kwargs = {
252+
'spec_annotations': {'iam.amazonaws.com/role': 'role-arn'},
253+
}
254+
deployment = self.create(**kwargs)
255+
data = self.scheduler.deployment.get(self.namespace, deployment).json()
256+
257+
self.assertDictContainsSubset(
258+
{
259+
'iam.amazonaws.com/role': 'role-arn'
260+
},
261+
data['spec']['template']['metadata']['annotations']
262+
)
263+
264+
def test_get_pod_annotations(self):
265+
"""
266+
Look at the Pod annotations that the Deployment created
267+
"""
268+
kwargs = {
269+
'spec_annotations': {
270+
'iam.amazonaws.com/role': 'role-arn-pods',
271+
'nginx.ingress.kubernetes.io/app-root': '/rootfs',
272+
'sidecar.istio.io/inject': 'true'
273+
},
274+
}
275+
deployment = self.create(**kwargs)
276+
data = self.scheduler.deployment.get(self.namespace, deployment).json()
277+
self.assertEqual(data['kind'], 'Deployment')
278+
self.assertEqual(data['metadata']['name'], deployment)
279+
280+
labels = {'app': self.namespace, 'version': 'v99', 'type': 'web'}
281+
pods = self.scheduler.pod.get(self.namespace, labels=labels).json()
282+
self.assertDictEqual(
283+
{
284+
'iam.amazonaws.com/role': 'role-arn-pods',
285+
'nginx.ingress.kubernetes.io/app-root': '/rootfs',
286+
'sidecar.istio.io/inject': 'true'
287+
},
288+
pods['items'][0]['metadata']['annotations']
289+
)
290+
246291
def test_check_for_failed_events(self):
247292
deploy_name = self.create(self.namespace)
248293
deployment = self.scheduler.deployment.get(self.namespace, deploy_name).json()

0 commit comments

Comments
 (0)