Since my company uses karma to show alerts(I have no access to prometheus/thanos in production) I've incorporated karma into my test automation CD/CI stack.
It works fine, but I have a few challenges:
The simplest would be to just export a json of alerts and their properties when giving a parameter, then I do not need
chrome,chromedriver and selenium in the container, just use a rest-api.
Under is an excerp of my current test using python and selenium:
totalAlerts = 0
alertNames = []
try:
el = wd.find_element(By.XPATH, "//div[@class='text-center d-inline-block cursor-pointer navbar-brand m-0 components-navbar-button components-animation-flash-enter-done components-animation-flash-exit-done']")
log.warning(f"total elements: {el.text}")
totalAlerts = int(el.text)
except (NoSuchElementException, ElementNotInteractableException) as e:
log.info("No warnings found all ok")
sys.exit(0)
try:
# we only get first page
els = wd.find_elements(By.XPATH, "//span[@class='components-label-name' and contains(text(), 'alertname')]/following-sibling::span")
log.info(f" we found {len(els)} alerts on first page they we can show")
for el in els:
log.info(f"alertname:{el.text}")
alertNames.append(el.text)
except (NoSuchElementException, ElementNotInteractableException) as e:
log.info("unable to parse alert components")
else:
# we should fail if we find any alerts
assert totalAlerts==0, f"no alerts but we got the following:{alertNames}"
output:
20220211131126|INFO|karma url: https://xxx.xxxxxxxx.xxx/?q=namespace%3D~.%2Bpayment.%2B
20220211131131|WARNING|total elements: 7
20220211131131|INFO| we found 6 alerts on first page they we can show
20220211131131|INFO|alertname:KubernetesPodNotHealthy
20220211131131|INFO|alertname:KubeContainerWaiting
20220211131131|INFO|alertname:KubernetesDeploymentReplicasMismatch
20220211131131|INFO|alertname:KubePodNotReady
20220211131132|INFO|alertname:KubeDeploymentReplicasMismatch
20220211131132|INFO|alertname:KubernetesDeploymentReplicasMismatch
Owner Name | prymitive |
Repo Name | karma |
Full Name | prymitive/karma |
Language | TypeScript |
Created Date | 2018-09-09 |
Updated Date | 2023-03-17 |
Star Count | 1921 |
Watcher Count | 33 |
Fork Count | 166 |
Issue Count | 2 |
Issue Title | Created Date | Updated Date |
---|