Skip to content

Commit

Permalink
Add e2e test for support bundle collection
Browse files Browse the repository at this point in the history
Signed-off-by: Shawn Wang <wshaoquan@vmware.com>
  • Loading branch information
wsquan171 committed Nov 30, 2022
1 parent 6300d86 commit 1616468
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ci/jenkins/test-vmc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ function deliver_antrea {

control_plane_ip="$(kubectl get nodes -o wide --no-headers=true | awk -v role="$CONTROL_PLANE_NODE_ROLE" '$3 ~ role {print $6}')"

${GIT_CHECKOUT_DIR}/hack/generate-manifest.sh --ch-size 100Mi --ch-monitor-threshold 0.1 > ${GIT_CHECKOUT_DIR}/build/yamls/flow-visibility.yml
${GIT_CHECKOUT_DIR}/hack/generate-manifest.sh --ch-size 100Mi --ch-monitor-threshold 0.1 --theia-manager > ${GIT_CHECKOUT_DIR}/build/yamls/flow-visibility.yml
${GIT_CHECKOUT_DIR}/hack/generate-manifest.sh --no-grafana --spark-operator --theia-manager > ${GIT_CHECKOUT_DIR}/build/yamls/flow-visibility-with-spark.yml
${GIT_CHECKOUT_DIR}/hack/generate-manifest.sh --no-grafana > ${GIT_CHECKOUT_DIR}/build/yamls/flow-visibility-ch-only.yml

Expand Down
2 changes: 1 addition & 1 deletion ci/kind/test-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function print_usage {

TESTBED_CMD=$(dirname $0)"/kind-setup.sh"
YML_DIR=$(dirname $0)"/../../build/yamls"
FLOW_VISIBILITY_CMD=$(dirname $0)"/../../hack/generate-manifest.sh --ch-size 100Mi --ch-monitor-threshold 0.1"
FLOW_VISIBILITY_CMD=$(dirname $0)"/../../hack/generate-manifest.sh --ch-size 100Mi --ch-monitor-threshold 0.1 --theia-manager"
FLOW_VISIBILITY_WITH_SPARK_CMD=$(dirname $0)"/../../hack/generate-manifest.sh --no-grafana --spark-operator --theia-manager"
FLOW_VISIBILITY_CH_ONLY_CMD=$(dirname $0)"/../../hack/generate-manifest.sh --no-grafana"
CH_OPERATOR_YML=$(dirname $0)"/../../build/charts/theia/crds/clickhouse-operator-install-bundle.yaml"
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/flowvisibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,12 @@ func testHelper(t *testing.T, data *TestData, podAIPs, podBIPs, podCIPs, podDIPs
}
checkClickHouseMonitor(t, data, isIPv6, flow)
})

// SupportBundle tests collection of log bundle via Theia CLI is successful
// and contains log files from common components in the test setup.
t.Run("SupportBundle", func(t *testing.T) {
testSupportBundleCollection(t, data)
})
}

func checkGrafanaQueryResults(t *testing.T, data *TestData, dashboardName, dashboardUid string, queryList *[]query) {
Expand Down
90 changes: 90 additions & 0 deletions test/e2e/supportbundle_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package e2e

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
)

const (
bundleCollectCmd = "./theia supportbundle -d ./support-bundle"
bundleExpandCmd = "tar -xvzf ./support-bundle/theia-support-bundle.tar.gz -C ./support-bundle"
)

func testSupportBundleCollection(t *testing.T, data *TestData) {
err := collectBundle(t, data)
require.NoError(t, err)
for _, tc := range supportBundleTestCases {
err = checkFileExists(t, data, "./support-bundle/logs", tc.filePath, tc.filenames)
if err != nil {
t.Errorf("Error when checking log file in support bundle, err: %v", err)
failOnError(err, t, data)
}
}
}

func collectBundle(t *testing.T, data *TestData) error {
cmd := "chmod +x ./theia"
rc, stdout, stderr, err := data.RunCommandOnNode(controlPlaneNodeName(), cmd)
if err != nil || rc != 0 {
return fmt.Errorf("error when running %s from %s: %v\nstdout:%s\nstderr:%s", cmd, controlPlaneNodeName(), err, stdout, stderr)
}
rc, stdout, stderr, err = data.RunCommandOnNode(controlPlaneNodeName(), bundleCollectCmd)
if err != nil || rc != 0 {
return fmt.Errorf("error when running %s from %s: %v\nstdout:%s\nstderr:%s", cmd, controlPlaneNodeName(), err, stdout, stderr)
}
rc, stdout, stderr, err = data.RunCommandOnNode(controlPlaneNodeName(), bundleExpandCmd)
if err != nil || rc != 0 {
return fmt.Errorf("error when running %s from %s: %v\nstdout:%s\nstderr:%s", cmd, controlPlaneNodeName(), err, stdout, stderr)
}
return nil
}

var supportBundleTestCases = []struct {
filePath string
filenames []string
}{
{
filePath: "clickhouse-server/chi-clickhouse-clickhouse-*",
filenames: []string{
"clickhouse-server.err.log",
"clickhouse-server.log",
},
},
{
filePath: "flow-aggregator/flow-aggregator-*",
filenames: []string{
"flow-aggregator.flow-aggregator-*.root.log.*",
},
},
{
filePath: "grafana/grafana-*",
filenames: []string{
"grafana.log",
},
},
{
filePath: "theia-manager",
filenames: []string{
"theia-manager.theia-manager-*.root.log.*",
},
},
{
filePath: "zookeeper/zookeeper-*",
filenames: []string{
"zookeeper-*.log",
},
},
}

func checkFileExists(t *testing.T, data *TestData, baseDir, filePath string, filenames []string) error {
for _, filename := range filenames {
cmd := fmt.Sprintf("ls -l %s/%s/%s", baseDir, filePath, filename)
rc, stdout, stderr, err := data.RunCommandOnNode(controlPlaneNodeName(), cmd)
if err != nil || rc != 0 {
return fmt.Errorf("error when running %s from %s: %v\nstdout:%s\nstderr:%s", cmd, controlPlaneNodeName(), err, stdout, stderr)
}
}
return nil
}

0 comments on commit 1616468

Please sign in to comment.