Skip to content

Commit

Permalink
Longw/metadata e2e test (#1266)
Browse files Browse the repository at this point in the history
* add unit test for containerlogv2 kubernetesmetadata

* update unit tests with more functional tests and empty tests

* e2e test for containerlogv2 and containerlogv2 metadata

* test containerlogv2 as default when ISTEST

* add collect all kube events for TEST
  • Loading branch information
wanlonghenry authored Jun 3, 2024
1 parent d98d627 commit 27d05ee
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ spec:
value: {{ .Values.amalogs.sidecarscraping | quote }}
- name: ENABLE_CUSTOM_METRICS
value: {{ .Values.amalogs.enableCustomMetrics | quote }}
{{ if .Values.amalogs.ISTEST }}
- name: AZMON_KUBERNETES_METADATA_ENABLED
value: "true"
{{- end }}
volumeMounts:
# Uncomment when telegraf upgraded to 1.28.5 or higher
# {{- if .Values.amalogs.enableServiceAccountTimeBoundToken }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ spec:
value: {{ .Values.Azure.proxySettings.isCustomCert | quote }}
- name: ENABLE_CUSTOM_METRICS
value: {{ .Values.amalogs.enableCustomMetrics | quote }}
{{ if .Values.amalogs.ISTEST }}
- name: AZMON_KUBERNETES_METADATA_ENABLED
value: "true"
{{- end }}
- name: HOSTNAME
valueFrom:
fieldRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ spec:
value: {{ .Values.Azure.proxySettings.isCustomCert | quote }}
- name: ENABLE_CUSTOM_METRICS
value: {{ .Values.amalogs.enableCustomMetrics | quote }}
{{ if .Values.amalogs.ISTEST }}
- name: AZMON_CLUSTER_COLLECT_ALL_KUBE_EVENTS
value: "true"
{{- end }}
- name: HOSTNAME
valueFrom:
fieldRef:
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/src/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
CONTAINER_PERF_MEMORY_WS_USAGE_QUERY = "Perf | where ObjectName == 'K8SContainer' | where CounterName == 'memoryWorkingSetBytes' | where TimeGenerated > ago({0}) | count"
CONTAINER_PERF_RESTART_TIME_EPOCH_QUERY = "Perf | where ObjectName == 'K8SContainer' | where CounterName == 'restartTimeEpoch' | where TimeGenerated > ago({0}) | count"
# container log
CONTAINER_LOG_QUERY = "ContainerLog | where TimeGenerated > ago({0}) | count"
CONTAINER_LOG_V2_QUERY = "ContainerLogV2 | where TimeGenerated > ago({0}) | count"
CONTAINER_LOG_V2_K8S_METADATA_QUERY = "ContainerLogV2 | where TimeGenerated > ago({0}) | where KubernetesMetadata != "" | count"

# insights metrics
INSIGHTS_METRICS_QUERY = "InsightsMetrics | where TimeGenerated > ago({0}) | count"

Expand Down
19 changes: 15 additions & 4 deletions test/e2e/src/tests/test_e2e_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,27 @@ def test_e2e_workflows(env_dict):
if not rowCount:
pytest.fail("rowCount should be greater than for cluster: {0} for workflow: {1} ".format(clusterResourceId, 'CONTAINER_PERF_RESTART_TIME_EPOCH'))

# Container log
query = constants.CONTAINER_LOG_QUERY.format(queryTimeInterval)
# Container log v2
query = constants.CONTAINER_LOG_V2_QUERY.format(queryTimeInterval)
params = { 'query': query}
result = requests.get(queryUrl, params=params, headers=Headers)
if not result:
pytest.fail("log analytics query response shouldnt be null or empty for workflow: {0}".format('CONTAINER_LOG'))
pytest.fail("log analytics query response shouldnt be null or empty for workflow: {0}".format('CONTAINER_LOG_V2'))

rowCount = result.json()['tables'][0]['rows'][0][0]
if not rowCount:
pytest.fail("rowCount should be greater than for cluster: {0} for workflow: {1} ".format(clusterResourceId, 'CONTAINER_LOG'))
pytest.fail("rowCount should be greater than for cluster: {0} for workflow: {1} ".format(clusterResourceId, 'CONTAINER_LOG_V2'))

# Container log v2 Kubernetes Metadata
query = constants.CONTAINER_LOG_V2_K8S_METADATA_QUERY.format(queryTimeInterval)
params = { 'query': query}
result = requests.get(queryUrl, params=params, headers=Headers)
if not result:
pytest.fail("log analytics query response shouldnt be null or empty for workflow: {0}".format('CONTAINER_LOG_V2_K8S_METADATA'))

rowCount = result.json()['tables'][0]['rows'][0][0]
if not rowCount:
pytest.fail("rowCount should be greater than for cluster: {0} for workflow: {1} ".format(clusterResourceId, 'CONTAINER_LOG_V2_K8S_METADATA'))

# InsightsMetrics
query = constants.INSIGHTS_METRICS_QUERY.format(queryTimeInterval)
Expand Down

0 comments on commit 27d05ee

Please sign in to comment.