Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml based assertion #6

Open
AmitKumarDas opened this issue Feb 26, 2020 · 1 comment
Open

yaml based assertion #6

AmitKumarDas opened this issue Feb 26, 2020 · 1 comment
Assignees
Labels

Comments

@AmitKumarDas
Copy link

As a developer I want to use better assertion logic than the following:

- name: Fetch OpenEBS control plane pods ready status
  shell: kubectl get pods -n openebs | grep {{ item }} | awk '{print $2}' | awk -F'/' '{print $1}' && kubectl get pods -n openebs | grep {{ item }} | awk '{print $2}' | awk -F'/' '{print $2}'
  register: ready_status
  with_items:
    - '{{ openebs_components }}'
  until: '{{ ready_status.stdout_lines | unique | length == 1 }}'
  retries: 20
  delay: 5

It will be great to assert list of values in a declarative manner.

For example below yaml should be enough to assert any Pods with the given label to be in Running state. It should return error if there are any Pods that are not Running.

kind: Pod
metadata:
  labels:
    name: app
status:
  phase: Running
@AmitKumarDas
Copy link
Author

AmitKumarDas commented Feb 26, 2020

UseCase 1: To further our expectation of declarative assertion, let us try to assert any Deployment that has one of its containers with a nginx image with name my-nginx.
Solution: The assertion yaml should look like below:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
      - name: my-nginx
        image: nginx

UseCase 2: Assert any Deployment that has nginx image with container port 80
Solution: The assertion yaml should look like following:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
      - image: nginx
        ports:
        - containerPort: 80

UseCase 3: Assert 3 Pods with label app:run in Running state
Solution: The assertion yaml should look like following:

kind: PodList
count: 3
items:
- kind: Pod
  metadata:
    labels:
      app: run
  status:
    phase: Running

UseCase 4: Assert 2 Pods with label app:run & app:running in Running state
Solution: The assertion yaml should look like following:

kind: PodList
items:
- kind: Pod
  metadata:
    labels:
      app: run
  status:
    phase: Running
- kind: Pod
  metadata:
    labels:
      app: running
  status:
    phase: Running

@AmitKumarDas AmitKumarDas changed the title recipe: yaml based assertion yaml based assertion Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants