def _assert_status(): status = FiaasApplicationStatus.get( create_name(name, DEPLOYMENT_ID1)) assert status.result == u"RUNNING" assert len(status.logs) > 0 assert any("Saving result RUNNING for default/{}".format(name) in l for l in status.logs)
def test_custom_resource_definition_deploy(self, custom_resource_definition, service_type, kind_logger): with kind_logger(): name, fiaas_application, expected = custom_resource_definition # check that k8s objects for name doesn't already exist kinds = self._select_kinds(expected) for kind in kinds: with pytest.raises(NotFound): kind.get(name) # First deploy fiaas_application.save() app_uid = fiaas_application.metadata.uid # Check that deployment status is RUNNING def _assert_status(): status = FiaasApplicationStatus.get(create_name(name, DEPLOYMENT_ID1)) assert status.result == u"RUNNING" assert len(status.logs) > 0 assert any("Saving result RUNNING for default/{}".format(name) in line for line in status.logs) wait_until(_assert_status, patience=PATIENCE) # Check that annotations and labels are applied to status object status_labels = fiaas_application.spec.additional_labels.status if status_labels: status = FiaasApplicationStatus.get(create_name(name, DEPLOYMENT_ID1)) label_difference = status_labels.viewitems() - status.metadata.labels.viewitems() assert label_difference == set() # Check deploy success wait_until(_deploy_success(name, kinds, service_type, IMAGE1, expected, DEPLOYMENT_ID1, app_uid=app_uid), patience=PATIENCE) # Redeploy, new image, possibly new init-container fiaas_application.spec.image = IMAGE2 fiaas_application.metadata.labels["fiaas/deployment_id"] = DEPLOYMENT_ID2 strongbox_groups = [] if "strongbox" in name: strongbox_groups = ["foo", "bar"] fiaas_application.spec.config["extensions"]["strongbox"]["groups"] = strongbox_groups fiaas_application.save() app_uid = fiaas_application.metadata.uid # Check success wait_until(_deploy_success(name, kinds, service_type, IMAGE2, expected, DEPLOYMENT_ID2, strongbox_groups, app_uid=app_uid), patience=PATIENCE) # Cleanup FiaasApplication.delete(name) def cleanup_complete(): for kind in kinds: with pytest.raises(NotFound): kind.get(name) wait_until(cleanup_complete, patience=PATIENCE)
def test_create_name(self, deployment_id): final_name = status.create_name(NAME, deployment_id) assert VALID_NAME.match(final_name), "Name is not valid"