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

[molecule] get tests to pass again #435

Merged
merged 1 commit into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions molecule/accessible-namespaces-test/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@
that:
- kiali_configmap.api.namespaces.label_selector == "kiali.io/member-of={{ istio.control_plane_namespace }}"

# TODO kubernetes.core.k8s behaves oddly - query doesn't return a list, but should; lookup returns a list but shouldn't.
# For now, just use lookup since it returns the list which is what we want
- name: Make sure the new label exists, but didn't overwrite any existing labels
vars:
namespacesWithCustomLabel: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='customLabel=test') }}"
namespacesWithKialiLabel: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector=kiali_configmap.api.namespaces.label_selector) }}"
# Use query - it is the only way to ensure a list is returned; for some reason, lookup/wantList=true is not working
namespacesWithCustomLabel: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector='customLabel=test') }}"
namespacesWithKialiLabel: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector=kiali_configmap.api.namespaces.label_selector) }}"
assert:
that:
- namespacesWithCustomLabel | length == 1
Expand Down
2 changes: 1 addition & 1 deletion molecule/common/purge-prometheus-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace: "{{ k8s_item.metadata.namespace }}"
name: "{{ k8s_item.metadata.name }}"
with_items:
- "{{ lookup('kubernetes.core.k8s', namespace=istio.control_plane_namespace, kind='Pod', label_selector='app=prometheus', api_version='v1') }}" # TODO this assumes faulty behavior - may need to change in the future. See: https://github.com/ansible-collections/kubernetes.core/issues/147
- "{{ query('kubernetes.core.k8s', namespace=istio.control_plane_namespace, kind='Pod', label_selector='app=prometheus', api_version='v1') }}"
loop_control:
loop_var: k8s_item

Expand Down
5 changes: 4 additions & 1 deletion molecule/common/query-prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
pod: "{{ kiali_pod.resources[0].metadata.name}}"
command: "curl -skL {{ credentials_arg }} -d query={{ prometheus_request.query}} -d time={{ prometheus_request.time }} {{ url }}"
register: prometheus_query_results_raw
ignore_errors: yes # TODO why is this returning a rc=3? We are getting back good results
vars:
credentials_arg: "{{ ('-u ' + kiali_configmap.external_services.prometheus.auth.username + ':' + kiali_configmap.external_services.prometheus.auth.password) if kiali_configmap.external_services.prometheus.auth.username != '' else '' }}"
url: "{{ kiali_configmap.external_services.prometheus.url }}/api/v1/query }}"

- name: Raw Prometheus query results
vars:
url: "{{ kiali_configmap.external_services.prometheus.url }}/api/v1/query }}"
debug:
msg: "Request: {{ prometheus_request }}; Results: {{ prometheus_query_results_raw }}"
msg: "URL: {{ url }}; Request: {{ prometheus_request }}; Results: {{ prometheus_query_results_raw }}"

- set_fact:
prometheus_query_results:
Expand Down
Loading