Skip to content

Commit

Permalink
test(e2e): add e2e action for operator manifest (#488)
Browse files Browse the repository at this point in the history
* add e2e action for operator

* add wait action

* add test case for risingwave.yaml

* update the e2e action

* update hdfs manifest file

* add manifeat test shell and shfmt

* add shfmt make command

* update action file

* remove the hdfs test

* fix risingwave-in-memory.yaml
  • Loading branch information
bigfish.zhang authored Aug 3, 2023
1 parent a98b5bf commit 5bd9701
Show file tree
Hide file tree
Showing 30 changed files with 1,617 additions and 1,432 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/e2e_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: E2E Manifest Test (PR)

on:
workflow_dispatch: # For manually triggering workflow
pull_request:
branches: [ main ]
merge_group:
branches: [ main ]

jobs:
e2e-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create Kind Cluster
uses: helm/kind-action@v1.8.0
- name: Install Cert Manager
shell: bash
working-directory: ./
run: |
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.12.0/cert-manager.yaml
- name: Wait Cert Manager
working-directory: ./
if: ${{ always() }}
run: |
curl -sSL -o cmctl.tar.gz https://github.com/cert-manager/cert-manager/releases/download/v1.12.0/cmctl-linux-amd64.tar.gz
tar xzf cmctl.tar.gz
sudo mv cmctl /usr/local/bin
cmctl check api --wait=2m
- name: Install Operator
shell: bash
working-directory: ./
if: ${{ always() }}
run: |
kubectl apply --server-side -f config/risingwave-operator.yaml
- name: Wait Operator
shell: bash
working-directory: ./
if: ${{ always() }}
run: |
kubectl wait --for=condition=Ready Pods --all --namespace risingwave-operator-system --timeout=5m
- name: E2E Manifest Test
shell: bash
working-directory: ./
if: ${{ always() }}
run: |
make manifest-test
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ build-e2e-image:
e2e-test: generate-test-yaml vendor build-e2e-image
E2E_KUBERNETES_RUNTIME=kind ./test/e2e/e2e.sh
manifest-test:
./test/e2e/e2e.sh -m
docker-cross-build: test buildx## Build docker image with the manager.
docker buildx build -f build/Dockerfile --build-arg USE_VENDOR=false --build-arg VERSION="$(shell git describe --tags)" --platform=linux/amd64,linux/arm64 -t ${IMG} . --push
Expand Down Expand Up @@ -327,3 +330,11 @@ CI_RUNNER_IMAGE := public.ecr.aws/w6q9k3j5/rw-operator-ci-runner:$(shell date +'
build-ci-runner-image:
docker buildx build --platform linux/amd64,linux/arm64 -f ci/runner/Dockerfile -t $(CI_RUNNER_IMAGE) . --push
SHFMT = $(shell pwd)/bin/$(OS)/shfmt
ensure_shfmt: ## Download shfmt locally if necessary.
# $(call get-golangci-lint)
$(call go-get-tool,$(SHFMT),mvdan.cc/sh/v3/cmd/shfmt@latest)
shfmt: shellcheck ensure_shfmt
shfmt -s -w .
36 changes: 18 additions & 18 deletions ci/run-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ mkdir -p ci/run && env | grep "BUILDKITE\|CI\|AWS" >ci/run/env.list
# Get environment variables from the command line
env_args=""
while getopts ":e:" opt; do
case ${opt} in
e)
[[ -v "${OPTARG}" ]] && env_args+="-e ${OPTARG} "
;;
\?)
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
:)
echo "Invalid option: $OPTARG requires an argument" 1>&2
exit 1
;;
esac
case ${opt} in
e)
[[ -v ${OPTARG} ]] && env_args+="-e ${OPTARG} "
;;
\?)
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
:)
echo "Invalid option: $OPTARG requires an argument" 1>&2
exit 1
;;
esac
done

# Get the arguments after the options
shift $((OPTIND - 1))

# shellcheck disable=SC2086
docker run --rm --userns=host --privileged --network host \
${env_args} --env-file ci/run/env.list \
-v "$(pwd):/workspace" -w /workspace \
-v /var/run/docker.sock:/var/run/docker.sock \
--entrypoint bash \
"${CI_BASE_IMAGE}" "$@"
${env_args} --env-file ci/run/env.list \
-v "$(pwd):/workspace" -w /workspace \
-v /var/run/docker.sock:/var/run/docker.sock \
--entrypoint bash \
"${CI_BASE_IMAGE}" "$@"
2 changes: 1 addition & 1 deletion ci/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -euo pipefail

echo "--- Build binaries"

make build
make build
2 changes: 1 addition & 1 deletion ci/scripts/docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

set -euo pipefail
set -euo pipefail
2 changes: 1 addition & 1 deletion ci/scripts/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ kind delete cluster --name e2e

echo "--- Running e2e tests"

make e2e-test
make e2e-test
78 changes: 39 additions & 39 deletions ci/scripts/run-static-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -euo pipefail
exit_code=0

function mark_fail() {
echo $1
exit_code=$2
echo $1
exit_code=$2
}

echo "--- Running spell checks"
Expand All @@ -20,20 +20,20 @@ make shellcheck || mark_fail "Shell check failed" $?
echo "--- Running go mod tidy"

function go_mod_tidy_check() {
local exit_code=0
local go_mod_tidy_output
go_mod_tidy_output=$(go mod tidy -v 2>&1) || exit_code=$?
if [[ $exit_code -ne 0 ]]; then
echo "go mod tidy failed:"
echo "$go_mod_tidy_output"
return 1
fi
if [[ -n "$go_mod_tidy_output" ]] && echo "$go_mod_tidy_output" | grep -q -v "go: downloading"; then
echo "go mod tidy modified go.mod or go.sum:"
echo "$go_mod_tidy_output"
return 1
fi
return 0
local exit_code=0
local go_mod_tidy_output
go_mod_tidy_output=$(go mod tidy -v 2>&1) || exit_code=$?
if [[ $exit_code -ne 0 ]]; then
echo "go mod tidy failed:"
echo "$go_mod_tidy_output"
return 1
fi
if [[ -n $go_mod_tidy_output ]] && echo "$go_mod_tidy_output" | grep -q -v "go: downloading"; then
echo "go mod tidy modified go.mod or go.sum:"
echo "$go_mod_tidy_output"
return 1
fi
return 0
}

go_mod_tidy_check || mark_fail "go mod tidy failed" $?
Expand All @@ -45,20 +45,20 @@ go mod vendor || mark_fail "go mod vendor failed" $?
echo "--- Running go fmt"

function go_fmt_check() {
local exit_code=0
local go_fmt_output
go_fmt_output=$(go fmt ./... 2>&1) || exit_code=$?
if [[ $exit_code -ne 0 ]]; then
echo "go fmt failed:"
echo "$go_fmt_output"
return 1
fi
if [[ -n "$go_fmt_output" ]]; then
echo "go fmt modified files:"
echo "$go_fmt_output"
return 1
fi
return 0
local exit_code=0
local go_fmt_output
go_fmt_output=$(go fmt ./... 2>&1) || exit_code=$?
if [[ $exit_code -ne 0 ]]; then
echo "go fmt failed:"
echo "$go_fmt_output"
return 1
fi
if [[ -n $go_fmt_output ]]; then
echo "go fmt modified files:"
echo "$go_fmt_output"
return 1
fi
return 0
}

go_fmt_check || mark_fail "go fmt failed" $?
Expand All @@ -72,10 +72,10 @@ echo "--- Generating YAML files"
make generate-yaml generate-test-yaml || mark_fail "YAML generation failed" $?

function yaml_change_check() {
if git status --porcelain | grep -q 'config/risingwave-operator.*.yaml'; then
echo "YAML files changed, please run 'make generate-yaml generate-test-yaml' and commit the changes"
return 1
fi
if git status --porcelain | grep -q 'config/risingwave-operator.*.yaml'; then
echo "YAML files changed, please run 'make generate-yaml generate-test-yaml' and commit the changes"
return 1
fi
}

yaml_change_check || mark_fail "YAML files changed" $?
Expand All @@ -85,15 +85,15 @@ echo "--- Generating docs"
make generate-docs || mark_fail "Docs generation failed" $?

function docs_change_check() {
if git status --porcelain | grep -q docs/; then
echo "Docs changed, please run 'make generate-docs' and commit the changes"
return 1
fi
if git status --porcelain | grep -q docs/; then
echo "Docs changed, please run 'make generate-docs' and commit the changes"
return 1
fi
}
docs_change_check || mark_fail "Docs changed" $?

echo "--- Running lint checks"

make lint || mark_fail "Lint failed" $?

exit $exit_code
exit $exit_code
2 changes: 1 addition & 1 deletion ci/scripts/run-unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ go test ./... -coverprofile cover.out.tmp || exit $?
grep -v "_generated.go" <cover.out.tmp >cover.out && rm -f cover.out.tmp

echo "--- Report coverage to codecov.io"
codecov -t "$CI_CODECOV_TOKEN" -f cover.out -F unittests -v
codecov -t "$CI_CODECOV_TOKEN" -f cover.out -F unittests -v
2 changes: 2 additions & 0 deletions docs/general/state-stores.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ spec:

## Apache HDFS / WebHDFS

(Note: The standard image do not support HDFS. Please get in touch with us to get the latest available image tag)

```yamlex
spec:
stateStore:
Expand Down
76 changes: 61 additions & 15 deletions docs/manifests/risingwave/risingwave-etcd-hdfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -388,19 +388,65 @@ kind: RisingWave
metadata:
name: risingwave-etcd-hdfs
spec:
storages:
image: ghcr.io/risingwavelabs/risingwave:YOUR_LATEST_HDFS_TAG
metaStore:
etcd:
endpoint: risingwave-etcd:2388
stateStore:
dataDirectory: hummock
hdfs:
nameNode: hadoop-hdfs-master:9000
root: risingwave
components:
meta:
etcd:
endpoint: risingwave-etcd:2388
object:
hdfs:
nameNode: hadoop-hdfs-master:9000
root: risingwave
global:
image: ghcr.io/risingwavelabs/risingwave:v1.0.0
imagePullPolicy: IfNotPresent
replicas:
meta: 1
frontend: 1
compute: 1
compactor: 1
nodeGroups:
- replicas: 1
name: ""
template:
spec:
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 100m
memory: 100Mi
frontend:
nodeGroups:
- replicas: 1
name: ""
template:
spec:
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 100m
memory: 100Mi
compute:
nodeGroups:
- replicas: 1
name: ""
template:
spec:
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 100m
memory: 100Mi
compactor:
nodeGroups:
- replicas: 1
name: ""
template:
spec:
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 100m
memory: 100Mi
Loading

0 comments on commit 5bd9701

Please sign in to comment.