def storage_pod_test_result(kubeconfig): try_ = retry(5) while next(try_): test_pv = get_kube_resources(kubeconfig, 'pod', name='test-pv') if test_pv.status.phase in ['Succeeded', 'Failed']: break assert test_pv.status.phase == 'Succeeded'
def check_quantity_storage_in_state(quantity, state, kubeconfig): assert quantity in ['No', 'Some'] nb = ['No', 'Some'].index(quantity) for _ in retry(5): pv_count = count_pv(get_kubernetes_pv(kubeconfig)) if bool(nb) == bool(pv_count[state]): break else: raise AssertionError("Could not meet '{}' '{}' pv in {}".format( quantity, state, pv_count))
def look_at_annotation_absence(request): try_ = retry(10, msg='Cannot meet the assertion') while next(try_): kube_object = request.get_kube_object() if isinstance(kube_object, V1beta1CronJob): metadata = kube_object.metadata else: metadata = kube_object.spec.template.metadata if metadata.annotations is None or \ 'metalk8s.io/test' not in metadata.annotations: break
def look_at_annotation(request): try_ = retry(10, msg='Cannot meet the assertion') while next(try_): kube_object = request.get_kube_object() if isinstance(kube_object, V1beta1CronJob): metadata = kube_object.metadata else: metadata = kube_object.spec.template.metadata if metadata.annotations is not None and \ metadata.annotations['metalk8s.io/test'] == 'true': break
def look_at_replicas_number(request, count): try_ = retry(10, msg='Cannot meet the assertion') while next(try_): kube_object = request.get_kube_object() if kube_object.spec.replicas == count: break