Skip to content
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
26 changes: 15 additions & 11 deletions test/e2e/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
func TestOperatorControllerMetricsExportedEndpoint(t *testing.T) {
client := utils.FindK8sClient(t)
curlNamespace := createRandomNamespace(t, client)
componentNamespace := getComponentNamespace(t, client, "app.kubernetes.io/name=operator-controller")
componentNamespace := getComponentNamespace(t, client, operatorManagerSelector)
metricsURL := fmt.Sprintf("https://operator-controller-service.%s.svc.cluster.local:8443/metrics", componentNamespace)

config := NewMetricsTestConfig(
Expand All @@ -52,7 +52,7 @@ func TestOperatorControllerMetricsExportedEndpoint(t *testing.T) {
func TestCatalogdMetricsExportedEndpoint(t *testing.T) {
client := utils.FindK8sClient(t)
curlNamespace := createRandomNamespace(t, client)
componentNamespace := getComponentNamespace(t, client, "app.kubernetes.io/name=catalogd")
componentNamespace := getComponentNamespace(t, client, catalogdManagerSelector)
metricsURL := fmt.Sprintf("https://catalogd-service.%s.svc.cluster.local:7443/metrics", componentNamespace)

config := NewMetricsTestConfig(
Expand Down Expand Up @@ -231,16 +231,20 @@ func createRandomNamespace(t *testing.T, client string) string {
}

// getComponentNamespace returns the namespace where operator-controller or catalogd is running
func getComponentNamespace(t *testing.T, client, selector string) string {
cmd := exec.Command(client, "get", "pods", "--all-namespaces", "--selector="+selector, "--output=jsonpath={.items[0].metadata.namespace}")
output, err := cmd.CombinedOutput()
require.NoError(t, err, "Error determining namespace: %s", string(output))

namespace := string(bytes.TrimSpace(output))
if namespace == "" {
t.Fatal("No namespace found for selector " + selector)
func getComponentNamespace(t *testing.T, client string, selectors []string) string {
for _, selector := range selectors {
cmd := exec.Command(client, "get", "pods", "--all-namespaces", "--selector="+selector, "--output=jsonpath={.items[0].metadata.namespace}")
output, err := cmd.CombinedOutput()
if err != nil {
continue
}
namespace := string(bytes.TrimSpace(output))
if namespace != "" {
return namespace
}
}
return namespace
t.Fatalf("No namespace found for selectors: %v", selectors)
return ""
}

func stdoutAndCombined(cmd *exec.Cmd) ([]byte, []byte, error) {
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/network_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ import (

const (
minJustificationLength = 40
catalogdManagerSelector = "app.kubernetes.io/name=catalogd"
operatorManagerSelector = "app.kubernetes.io/name=operator-controller"
catalogdMetricsPort = 7443
catalogdWebhookPort = 9443
catalogServerPort = 8443
operatorControllerMetricsPort = 8443
)

var (
catalogdManagerSelector = []string{"app.kubernetes.io/name=catalogd", "control-plane=catalogd-controller-manager"}
operatorManagerSelector = []string{"app.kubernetes.io/name=operator-controller", "control-plane=operator-controller-controller-manager"}
)

type portWithJustification struct {
port []networkingv1.NetworkPolicyPort
justification string
Expand Down