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

Add ServiceMonitor and E2E tests for Prometheus #286

Merged
merged 1 commit into from Mar 24, 2022

Conversation

borod108
Copy link
Contributor

@borod108 borod108 commented Jan 11, 2022

Add ServiceMonitor to seperate from kubevirts ServiceMonitor.
Add e2e tests for all Alerts

Signed-off-by: borod108 boris.od@gmail.com

ServiceMonitor added for the ssp-operator. A service added to the operator and TemplateValidator namespaces.
In case they are the same - only one service will be present.

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Jan 11, 2022
@borod108 borod108 changed the title Add ServiceMonitor and E2E tests for Prometheus [WIP] Add ServiceMonitor and E2E tests for Prometheus Jan 11, 2022
@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL labels Jan 11, 2022
@borod108 borod108 force-pushed the tests/prom_e2e branch 11 times, most recently from 4402400 to bf53528 Compare January 19, 2022 10:02
@borod108 borod108 force-pushed the tests/prom_e2e branch 4 times, most recently from 054898b to 8c7102c Compare January 20, 2022 13:57
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2022
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 27, 2022
@borod108 borod108 force-pushed the tests/prom_e2e branch 5 times, most recently from dfce1c8 to a3709e1 Compare January 30, 2022 16:12
@borod108 borod108 force-pushed the tests/prom_e2e branch 4 times, most recently from dbf2d6d to 0cc57f6 Compare March 16, 2022 10:44
@borod108
Copy link
Contributor Author

Changes applied, thank you!

@borod108
Copy link
Contributor Author

/retest

1 similar comment
@borod108
Copy link
Contributor Author

/retest

internal/operands/metrics/reconcile.go Show resolved Hide resolved
internal/operands/template-validator/reconcile.go Outdated Show resolved Hide resolved
internal/operands/template-validator/reconcile.go Outdated Show resolved Hide resolved
internal/operands/template-validator/reconcile.go Outdated Show resolved Hide resolved
tests/misc_test.go Outdated Show resolved Hide resolved
tests/monitoring_test.go Outdated Show resolved Hide resolved
tests/monitoring_test.go Outdated Show resolved Hide resolved
tests/tests_suite_test.go Show resolved Hide resolved
@@ -895,6 +908,22 @@ func eventuallyFailToCreateVm(vm *kubevirtv1.VirtualMachine) bool {
}, shortTimeout).Should(Equal(metav1.StatusReasonInvalid), "Should have given the invalid error")
}

func failVmCreationToIncreaseRejectedVmsMetrics() {
rejectedCountBefore := totalRejectedVmsMetricsValue()
template := TemplateWithRules()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template is not deleted after the test. It will be deleted once the namespace is removed, but that will not happen, if the tests are executed with existing SSP CR.

Can you add code to delete it, so the namspace is not polluted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current code the template would not be deleted, if one of the Expect() calls panics.

Instead, can you create the template before this function is called, and pass it as a parameter? Then it can be deleted in AfterEach().

tests/validator_test.go Outdated Show resolved Hide resolved
@borod108 borod108 force-pushed the tests/prom_e2e branch 2 times, most recently from a44c926 to 4e47891 Compare March 22, 2022 14:16
Copy link
Collaborator

@akrejcir akrejcir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. I have just 3 more small comments.

internal/operands/metrics/reconcile.go Show resolved Hide resolved
tests/tests_suite_test.go Outdated Show resolved Hide resolved
@@ -895,6 +908,22 @@ func eventuallyFailToCreateVm(vm *kubevirtv1.VirtualMachine) bool {
}, shortTimeout).Should(Equal(metav1.StatusReasonInvalid), "Should have given the invalid error")
}

func failVmCreationToIncreaseRejectedVmsMetrics() {
rejectedCountBefore := totalRejectedVmsMetricsValue()
template := TemplateWithRules()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current code the template would not be deleted, if one of the Expect() calls panics.

Instead, can you create the template before this function is called, and pass it as a parameter? Then it can be deleted in AfterEach().

tests/monitoring_test.go Outdated Show resolved Hide resolved
tests/monitoring_test.go Show resolved Hide resolved
@borod108 borod108 force-pushed the tests/prom_e2e branch 2 times, most recently from f29675b to fd55d0d Compare March 23, 2022 04:24
Add ServiceMonitor to seperate from kubevirts ServiceMonitor.
Add e2e tests for all Alerts.

Signed-off-by: borod108 <boris.od@gmail.com>
@sonarcloud
Copy link

sonarcloud bot commented Mar 23, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@openshift-ci
Copy link

openshift-ci bot commented Mar 23, 2022

@borod108: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-upgrade-from-old-operator-functests d60ec2b link true /test e2e-upgrade-from-old-operator-functests

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@akrejcir
Copy link
Collaborator

The CI failure probably means that CI is not testing what we expect. There is no template with os.template.kubevirt.io/ubuntu21.10 label in the current PR, or in the latest released version of SSP.

I will look into it.

@akrejcir
Copy link
Collaborator

Ignore my previous comment. The CI is correct. It is not testing this PR, but a merge commit of master branch and this PR.

Can you try rebasing this PR on top of master? Maybe the the merge in CI is incorrect.

@borod108
Copy link
Contributor Author

/retest

@akrejcir
Copy link
Collaborator

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 23, 2022
componentAlertLabelKey = "kubernetes_operator_component"
componentAlertLabelValue = "ssp-operator"
PrometheusRuleName = "prometheus-k8s-rules-cnv"
MonitorNamespace = "openshift-monitoring"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it only work in OpenShift?
I think it should work for both monitoring and openshift-monitoring namespaces...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will only work in openshift (the operator is working with templates that only work on openshift anyway)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akrejcir
Copy link
Collaborator

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: akrejcir

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 24, 2022
@kubevirt-bot kubevirt-bot merged commit 15b23ca into kubevirt:master Mar 24, 2022
@borod108 borod108 deleted the tests/prom_e2e branch July 12, 2022 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants