Skip to content

Commit

Permalink
e2e test changes
Browse files Browse the repository at this point in the history
Signed-off-by: Yanjun Zhou <[email protected]>
  • Loading branch information
yanjunz97 committed Jul 26, 2023
1 parent 3bcd4b2 commit 0df2c83
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -78,6 +76,7 @@ spec:
ports:
- name: http
port: {{ .Values.clickhouse.service.httpPort }}
targetPort: 8123
- name: tcp
port: {{ .Values.clickhouse.service.tcpPort }}
targetPort: 9000
Expand Down
4 changes: 1 addition & 3 deletions build/yamls/flow-visibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7210,9 +7210,6 @@ spec:
replicasCount: 1
shardsCount: 1
name: clickhouse
settings:
http_port: 8123
tcp_port: 9000
profiles:
readonly/readonly: 1
settings:
Expand Down Expand Up @@ -7344,6 +7341,7 @@ spec:
ports:
- name: http
port: 8123
targetPort: 8123
- name: tcp
port: 9000
targetPort: 9000
Expand Down
64 changes: 23 additions & 41 deletions test/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0df2c83

Please sign in to comment.