Skip to content

Commit

Permalink
Add E2E tests and workflow (dragonflyoss#402)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <gaius.qi@gmail.com>
Co-authored-by: Jim Ma <majinjing3@gmail.com>
  • Loading branch information
gaius-qi and jim3ma authored Jul 8, 2021
1 parent 9fefd2f commit 60df3f6
Show file tree
Hide file tree
Showing 11 changed files with 411 additions and 25 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: E2E Test

on:
push:
branches: [main, release-*]
pull_request:
branches: [main, release-*]

env:
GO_VERSION: 1.15
KIND_VERSION: v0.11.1
CONTAINERD_VERSION: v1.5.2
GOPROXY: https://goproxy.io,direct

jobs:
skip_check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- name: Skip Check
id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
paths_ignore: '["**.md", "**.png", "**.jpg", "**.svg"]'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'

e2e_tests:
runs-on: ubuntu-latest
needs: skip_check
if: needs.skip_check.outputs.noop != 'true'

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Get dependencies
run: |
go mod vendor
go get github.com/onsi/ginkgo/ginkgo
- name: Set up containerd
uses: crazy-max/ghaction-setup-containerd@v1
with:
containerd-version: ${{ env.CONTAINERD_VERSION }}
config: ./test/testdata/containerd/config.toml

- name: Set up crictl
run: |
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.21.0/crictl-v1.21.0-linux-amd64.tar.gz
sudo tar zxvf crictl-v1.21.0-linux-amd64.tar.gz -C /usr/local/bin
sudo mv ./test/testdata/crictl/config.yaml /etc/crictl.yaml
rm -f crictl-v1.21.0-linux-amd64.tar.gz
- name: Setup Kind
uses: engineerd/setup-kind@v0.5.0
with:
version: ${{ env.KIND_VERSION }}
config: ./test/testdata/kind/config.yaml

- name: Build docker image
run: |
make docker-build
- name: Load docker image
run: |
make kind-load
- name: Helm install
run: |
helm lint ./deploy/charts/dragonfly
helm install --create-namespace --namespace dragonfly-system dragonfly ./deploy/charts/dragonfly
- name: Wait for running
run: kubectl -n dragonfly-system wait --for=condition=ready --all --timeout=10m pod

- name: Run E2E tests
run: make e2e-test-coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
flags: e2etests
47 changes: 46 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PROJECT_NAME := "d7y.io/dragonfly/v2"
DFGET_NAME := "dfget"
VERSION := "2.0.0"
PKG := "$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/ | grep -v '\(/manager/\)')
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/ | grep -v '\(/manager/\)' | grep -v '\(/test/\)')
GIT_COMMIT := $(shell git rev-parse --verify HEAD --short=7)
GIT_COMMIT_LONG := $(shell git rev-parse --verify HEAD)
DFGET_ARCHIVE_PREFIX := "$(DFGET_NAME)_$(GIT_COMMIT)"
Expand Down Expand Up @@ -190,6 +190,42 @@ test-coverage:
@cat cover.out >> coverage.txt
.PHONY: test-coverage

# Run E2E tests
e2e-test:
@ginkgo -v -r --failFast test/e2e --trace --progress
.PHONY: e2e-test

# Run E2E tests with coverage
e2e-test-coverage:
@ginkgo -v -r --failFast -cover test/e2e --trace --progress
@cat test/e2e/*.coverprofile >> coverage.txt
.PHONY: e2e-test-coverage

# Kind load dragonlfy
kind-load: kind-load-cdn kind-load-scheduler kind-load-dfdaemon
@echo "Kind load image done."
.PHONY: docker-build

# Run kind load docker-image cdn
kind-load-cdn:
@./hack/kind-load.sh cdn
.PHONY: kind-load-cdn

# Run kind load docker scheduler
kind-load-scheduler:
@./hack/kind-load.sh scheduler
.PHONY: kind-load-scheduler

# Run kind load docker dfget
kind-load-dfdaemon:
@./hack/kind-load.sh dfdaemon
.PHONY: kind-load-dfget

# Run kind load docker manager
kind-load-manager:
@./hack/kind-load.sh manager
.PHONY: kind-load-manager

# Run go generate
generate:
@go generate ${PKG_LIST}
Expand Down Expand Up @@ -230,6 +266,15 @@ help:
@echo "make build-dfget-man-page generate dfget man page"
@echo "make test run unittests"
@echo "make test-coverage run tests with coverage"
@echo "make e2e-test run e2e tests"
@echo "make e2e-test-coverage run e2e tests with coverage"
@echo "make swag-manager generate swagger api"
@echo "make kind-load-image kind load docker image"
@echo "make changelog generate CHANGELOG.md"
@echo "make kind-load-cdn kind load cdn docker image"
@echo "make kind-load-scheduler kind load scheduler docker image"
@echo "make kind-load-dfdaemon kind load dfdaemon docker image"
@echo "make kind-load-manager kind load manager docker image"
@echo "make changelog generate CHANGELOG.md"
@echo "make generate run go generate"
@echo "make clean clean"
12 changes: 10 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ require (
github.com/jarcoal/httpmock v1.0.8
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mcuadros/go-gin-prometheus v0.1.0
github.com/mitchellh/mapstructure v1.4.1
github.com/olekukonko/tablewriter v0.0.5
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.14.0
github.com/pborman/uuid v1.2.1
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.7.1 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/schollz/progressbar/v3 v3.8.2
github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b
Expand All @@ -49,8 +55,9 @@ require (
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
golang.org/x/text v0.3.5 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
golang.org/x/tools v0.1.4 // indirect
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect
google.golang.org/grpc v1.36.0
google.golang.org/protobuf v1.26.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
Expand All @@ -59,6 +66,7 @@ require (
gorm.io/datatypes v1.0.1
gorm.io/driver/mysql v1.0.5
gorm.io/gorm v1.21.6
k8s.io/apimachinery v0.20.1
honnef.co/go/tools v0.0.1-2020.1.3 // indirect
k8s.io/apimachinery v0.20.6
k8s.io/client-go v11.0.0+incompatible
)
Loading

0 comments on commit 60df3f6

Please sign in to comment.