-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkumar| refactoring test for create prometheue rule
- Loading branch information
Pankaj Kumar
authored and
Pankaj Kumar
committed
Dec 2, 2024
1 parent
0739c2c
commit c4e1ca8
Showing
4 changed files
with
83 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package utils | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
rancher "github.com/rancher/shepherd/clients/rancher" | ||
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3" | ||
"github.com/rancher/shepherd/extensions/kubectl" | ||
e2e "k8s.io/kubernetes/test/e2e/framework" | ||
) | ||
|
||
func DeployPrometheusRule(mySession *rancher.Client, yamlPath string) error { | ||
|
||
yamlContent, err := os.ReadFile(yamlPath) | ||
if err != nil { | ||
log.Fatalf("Failed to read file %s: %v", yamlPath, err) | ||
} | ||
|
||
importYamlInput := &management.ImportClusterYamlInput{ | ||
YAML: string(yamlContent), | ||
} | ||
|
||
apply := []string{"kubectl", "apply", "-f", "/root/.kube/my-pod.yaml"} | ||
prometheusRuleApply, err := kubectl.Command(mySession, importYamlInput, "local", apply, "") | ||
if err != nil { | ||
return err | ||
} | ||
e2e.Logf("Successfully fetchall: %v", prometheusRuleApply) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PrometheusRule | ||
metadata: | ||
annotations: | ||
prometheus-operator-validated: 'true' | ||
name: test-prometheus-rule | ||
namespace: cattle-monitoring-system | ||
spec: | ||
groups: | ||
- name: team-qa | ||
rules: | ||
- alert: test-qa-2025 | ||
annotations: | ||
message: Alerts | ||
summary: Validate Summry | ||
expr: vector(1) | ||
for: 0s | ||
labels: | ||
cluster_id: local | ||
cluster_name: local | ||
namespace: cattle-monitoring-system | ||
severity: critical |