From 0df2c834404b7548a36759cfaaa4a1a841119376 Mon Sep 17 00:00:00 2001 From: Yanjun Zhou Date: Wed, 26 Jul 2023 10:40:06 -0700 Subject: [PATCH] e2e test changes Signed-off-by: Yanjun Zhou --- .../clickhouse/clickhouseinstallation.yaml | 5 +- build/yamls/flow-visibility.yml | 4 +- test/e2e/framework.go | 64 +++++++------------ 3 files changed, 26 insertions(+), 47 deletions(-) diff --git a/build/charts/theia/templates/clickhouse/clickhouseinstallation.yaml b/build/charts/theia/templates/clickhouse/clickhouseinstallation.yaml index fa22aae88..632e97dab 100644 --- a/build/charts/theia/templates/clickhouse/clickhouseinstallation.yaml +++ b/build/charts/theia/templates/clickhouse/clickhouseinstallation.yaml @@ -22,10 +22,8 @@ spec: {{- end }} clusters: - name: "clickhouse" - settings: - tcp_port: 9000 # keep for localhost - http_port: {{ .Values.clickhouse.service.httpPort }} {{- if .Values.clickhouse.service.secureConnection.enable }} + settings: tcp_port_secure: {{ .Values.clickhouse.service.secureConnection.secureTcpPort }} https_port: {{ .Values.clickhouse.service.secureConnection.httpsPort }} secure: "yes" @@ -78,6 +76,7 @@ spec: ports: - name: http port: {{ .Values.clickhouse.service.httpPort }} + targetPort: 8123 - name: tcp port: {{ .Values.clickhouse.service.tcpPort }} targetPort: 9000 diff --git a/build/yamls/flow-visibility.yml b/build/yamls/flow-visibility.yml index d5d787411..5d05dfbcd 100644 --- a/build/yamls/flow-visibility.yml +++ b/build/yamls/flow-visibility.yml @@ -7210,9 +7210,6 @@ spec: replicasCount: 1 shardsCount: 1 name: clickhouse - settings: - http_port: 8123 - tcp_port: 9000 profiles: readonly/readonly: 1 settings: @@ -7344,6 +7341,7 @@ spec: ports: - name: http port: 8123 + targetPort: 8123 - name: tcp port: 9000 targetPort: 9000 diff --git a/test/e2e/framework.go b/test/e2e/framework.go index 9b57c08ca..3e6675290 100644 --- a/test/e2e/framework.go +++ b/test/e2e/framework.go @@ -975,21 +975,6 @@ func (data *TestData) createBusyboxPodOnNode(name string, ns string, nodeName st return data.createPodOnNode(name, ns, nodeName, busyboxImage, []string{"sleep", strconv.Itoa(sleepDuration)}, nil, nil, nil, hostNetwork, nil) } -// getClickHouseOperator retrieves the name of the ClickHouse Operator Pod (clickhouse-operator-*) running on a specific Node. -func (data *TestData) getClickHouseOperator() (*corev1.Pod, error) { - listOptions := metav1.ListOptions{ - LabelSelector: "app=clickhouse-operator", - } - pods, err := data.clientset.CoreV1().Pods(kubeNamespace).List(context.TODO(), listOptions) - if err != nil { - return nil, fmt.Errorf("failed to list Flow Aggregator Pod: %v", err) - } - if len(pods.Items) != 1 { - return nil, fmt.Errorf("expected *exactly* one Pod") - } - return &pods.Items[0], nil -} - // getFlowAggregator retrieves the name of the Flow-Aggregator Pod (flow-aggregator-*) running on a specific Node. func (data *TestData) getFlowAggregator() (*corev1.Pod, error) { listOptions := metav1.ListOptions{ @@ -1288,39 +1273,36 @@ func (data *TestData) deployFlowVisibility(config FlowVisibilitySetUpConfig) (ch return chSvc.Spec.ClusterIP, nil } -func (data *TestData) deployFlowVisibilityCommon(chOperatorYML, flowVisibilityYML string) error { - rc, _, _, err := data.provider.RunCommandOnNode(controlPlaneNodeName(), fmt.Sprintf("kubectl apply -f %s", chOperatorYML)) - if err != nil || rc != 0 { - return fmt.Errorf("error when deploying the ClickHouse Operator YML: %v\n is %s available on the control-plane Node?", err, chOperatorYML) - } - // Check for clickhouse operator pod running again for db connection establishment - var chOperatorPod *corev1.Pod - - if err = wait.Poll(2*time.Second, defaultTimeout, func() (bool, error) { - chOperatorPod, err = data.getClickHouseOperator() +func (data *TestData) waitForClickHouseOperator(timeout time.Duration) error { + err := wait.PollImmediate(defaultInterval, timeout, func() (bool, error) { + deployment, err := data.clientset.AppsV1().Deployments("kube-system").Get(context.TODO(), "clickhouse-operator", metav1.GetOptions{}) if err != nil { - return false, nil - } else { - return true, nil + return false, fmt.Errorf("error when retrieving ClickHouse Operator deployment: %v", err) } - }); err != nil { - return fmt.Errorf("error when getting clickhouse-operator Pod: %v", err) - } - - podName := chOperatorPod.Name - _, err = data.PodWaitFor(defaultTimeout*2, podName, kubeNamespace, func(p *corev1.Pod) (bool, error) { - for _, condition := range p.Status.Conditions { - if condition.Type == corev1.PodReady { - return condition.Status == corev1.ConditionTrue, nil - } + if deployment.Status.UnavailableReplicas == 0 { + return true, nil } + // Keep trying return false, nil }) - if err != nil { - _, stdout, stderr, podErr := data.provider.RunCommandOnNode(controlPlaneNodeName(), fmt.Sprintf("kubectl get pod %s -n %s -o yaml", podName, kubeNamespace)) - return fmt.Errorf("error when waiting for clickhouse-operator Ready: %v; stdout %s, stderr: %s, %v", err, stdout, stderr, podErr) + if err == wait.ErrWaitTimeout { + return fmt.Errorf("ClickHouse Operator is still unavailable after %v", defaultTimeout) + } else if err != nil { + return err } + return nil +} +func (data *TestData) deployFlowVisibilityCommon(chOperatorYML, flowVisibilityYML string) error { + rc, _, _, err := data.provider.RunCommandOnNode(controlPlaneNodeName(), fmt.Sprintf("kubectl apply -f %s", chOperatorYML)) + if err != nil || rc != 0 { + return fmt.Errorf("error when deploying the ClickHouse Operator YML: %v\n is %s available on the control-plane Node?", err, chOperatorYML) + } + // Check for clickhouse operator pod running + err = data.waitForClickHouseOperator(defaultTimeout) + if err != nil { + return fmt.Errorf("error when waiting for clickhouse-operator Ready: %v", err) + } if err := wait.Poll(2*time.Second, 10*time.Second, func() (bool, error) { rc, stdout, stderr, err := data.provider.RunCommandOnNode(controlPlaneNodeName(), fmt.Sprintf("kubectl apply -f %s", flowVisibilityYML)) if err != nil || rc != 0 {