Skip to content

Commit

Permalink
Add support for tags to molecule tests (ansible-collections#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
gravesm authored Apr 19, 2021
1 parent 28223db commit b68bf7c
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 142 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/62-molecule-tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- add support for using tags when running molecule test suite (https://github.com/ansible-collections/kubernetes.core/pull/62).
127 changes: 115 additions & 12 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,123 @@
assert:
that: (pod_list.resources | count) > 5

- include_tasks: tasks/delete.yml
- include_tasks: tasks/scale.yml
- include_tasks: tasks/apply.yml
- include_tasks: tasks/waiter.yml
- include_tasks: tasks/full.yml
- include_tasks: tasks/exec.yml
- include_tasks: tasks/log.yml
- include_tasks: tasks/cluster_info.yml
- include_tasks: tasks/access_review.yml
- include_tasks: tasks/rollback.yml
- include_tasks: tasks/gc.yml
- name: Include access_review.yml
include_tasks:
file: tasks/access_review.yml
apply:
tags: [ access_review, k8s ]
tags:
- always
- name: Include append_hash.yml
include_tasks:
file: tasks/append_hash.yml
apply:
tags: [ append_hash, k8s ]
tags:
- always
- name: Include apply.yml
include_tasks:
file: tasks/apply.yml
apply:
tags: [ apply, k8s ]
tags:
- always
- name: Include cluster_info.yml
include_tasks:
file: tasks/cluster_info.yml
apply:
tags: [ cluster_info, k8s ]
tags:
- always
- name: Include crd.yml
include_tasks:
file: tasks/crd.yml
apply:
tags: [ crd, k8s ]
tags:
- always
- name: Include delete.yml
include_tasks:
file: tasks/delete.yml
apply:
tags: [ delete, k8s ]
tags:
- always
- name: Include exec.yml
include_tasks:
file: tasks/exec.yml
apply:
tags: [ exec, k8s ]
tags:
- always
- name: Include full.yml
include_tasks:
file: tasks/full.yml
apply:
tags: [ full, k8s ]
tags:
- always
- name: Include gc.yml
include_tasks:
file: tasks/gc.yml
apply:
tags: [ gc, k8s ]
tags:
- always
- name: Include info.yml
include_tasks:
file: tasks/info.yml
apply:
tags: [ info, k8s ]
tags:
- always
- name: Include lists.yml
include_tasks:
file: tasks/lists.yml
apply:
tags: [ lists, k8s ]
tags:
- always
- name: Include log.yml
include_tasks:
file: tasks/log.yml
apply:
tags: [ log, k8s ]
tags:
- always
- name: Include rollback.yml
include_tasks:
file: tasks/rollback.yml
apply:
tags: [ rollback, k8s ]
tags:
- always
- name: Include scale.yml
include_tasks:
file: tasks/scale.yml
apply:
tags: [ scale, k8s ]
tags:
- always
- name: Include template.yml
include_tasks:
file: tasks/template.yml
apply:
tags: [ template, k8s ]
tags:
- always
- name: Include waiter.yml
include_tasks:
file: tasks/waiter.yml
apply:
tags: [ waiter, k8s ]
tags:
- always

roles:
- helm
- role: helm
tags:
- helm

post_tasks:
- name: Ensure namespace exists
Expand Down
4 changes: 0 additions & 4 deletions molecule/default/tasks/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@
register: k8s_info_testing6
failed_when: not k8s_info_testing6.resources or k8s_info_testing6.resources[0].status.phase != "Active"

- include_tasks: crd.yml
- include_tasks: lists.yml
- include_tasks: append_hash.yml

always:
- name: Delete all namespaces
k8s:
Expand Down
4 changes: 3 additions & 1 deletion molecule/default/tasks/info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
- block:
- set_fact:
wait_namespace: wait
k8s_pod_name: pod-info-1
multi_pod_one: multi-pod-1
multi_pod_two: multi-pod-2

Expand Down Expand Up @@ -200,6 +199,9 @@
that:
- "{{ lookup('pipe', 'date +%s') }} - {{ start }} > 30"

vars:
k8s_pod_name: pod-info-1

always:
- name: Remove namespace
k8s:
Expand Down
Loading

0 comments on commit b68bf7c

Please sign in to comment.