Run unit tests and coverage for operator api (#2010)
This commit is contained in:
57
.github/workflows/jobs.yaml
vendored
57
.github/workflows/jobs.yaml
vendored
@@ -1194,6 +1194,52 @@ jobs:
|
|||||||
./restapi/coverage/
|
./restapi/coverage/
|
||||||
key: ${{ runner.os }}-coverage-restapi-2-${{ github.run_id }}
|
key: ${{ runner.os }}-coverage-restapi-2-${{ github.run_id }}
|
||||||
|
|
||||||
|
test-operatorapi-on-go:
|
||||||
|
name: Test Operatorapi on Go ${{ matrix.go-version }} and ${{ matrix.os }}
|
||||||
|
needs:
|
||||||
|
- lint-job
|
||||||
|
- no-warnings-and-make-assets
|
||||||
|
- reuse-golang-dependencies
|
||||||
|
- vulnerable-dependencies-checks
|
||||||
|
- semgrep-static-code-analysis
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version: [ 1.17.x ]
|
||||||
|
os: [ ubuntu-latest ]
|
||||||
|
steps:
|
||||||
|
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
id: go
|
||||||
|
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
name: Go Mod Cache
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/go-build
|
||||||
|
~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ github.run_id }}
|
||||||
|
|
||||||
|
- name: Build on ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
GO111MODULE: on
|
||||||
|
GOOS: linux
|
||||||
|
run: |
|
||||||
|
make test-unit-test-operator
|
||||||
|
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
id: coverage-cache-unittest-operatorapi
|
||||||
|
name: Coverage Cache unit test operatorAPI
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
./operatorapi/coverage/
|
||||||
|
key: ${{ runner.os }}-coverage-unittest-operatorapi-2-${{ github.run_id }}
|
||||||
|
|
||||||
b-integration-tests:
|
b-integration-tests:
|
||||||
name: Integration Tests with Latest Distributed MinIO
|
name: Integration Tests with Latest Distributed MinIO
|
||||||
needs:
|
needs:
|
||||||
@@ -1286,6 +1332,7 @@ jobs:
|
|||||||
needs:
|
needs:
|
||||||
- b-integration-tests
|
- b-integration-tests
|
||||||
- test-restapi-on-go
|
- test-restapi-on-go
|
||||||
|
- test-operatorapi-on-go
|
||||||
- c-operator-api-tests
|
- c-operator-api-tests
|
||||||
- test-pkg-on-go
|
- test-pkg-on-go
|
||||||
- sso-integration
|
- sso-integration
|
||||||
@@ -1356,6 +1403,14 @@ jobs:
|
|||||||
./restapi/coverage/
|
./restapi/coverage/
|
||||||
key: ${{ runner.os }}-coverage-restapi-2-${{ github.run_id }}
|
key: ${{ runner.os }}-coverage-restapi-2-${{ github.run_id }}
|
||||||
|
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
id: coverage-cache-unittest-operatorapi
|
||||||
|
name: Coverage Cache unit test operatorAPI
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
./operatorapi/coverage/
|
||||||
|
key: ${{ runner.os }}-coverage-unittest-operatorapi-2-${{ github.run_id }}
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
id: coverage-cache-pkg
|
id: coverage-cache-pkg
|
||||||
name: Coverage Cache Pkg
|
name: Coverage Cache Pkg
|
||||||
@@ -1375,7 +1430,7 @@ jobs:
|
|||||||
echo "go build gocoverage.go"
|
echo "go build gocoverage.go"
|
||||||
go build gocovmerge.go
|
go build gocovmerge.go
|
||||||
echo "put together the outs for final coverage resolution"
|
echo "put together the outs for final coverage resolution"
|
||||||
./gocovmerge ../integration/coverage/system.out ../replication/coverage/replication.out ../sso-integration/coverage/sso-system.out ../restapi/coverage/coverage.out ../pkg/coverage/coverage-pkg.out ../operator-integration/coverage/operator-api.out > all.out
|
./gocovmerge ../integration/coverage/system.out ../replication/coverage/replication.out ../sso-integration/coverage/sso-system.out ../restapi/coverage/coverage.out ../pkg/coverage/coverage-pkg.out ../operator-integration/coverage/operator-api.out ../operatorapi/coverage/coverage-unit-test-operatorapi.out > all.out
|
||||||
echo "Download mc for Ubuntu"
|
echo "Download mc for Ubuntu"
|
||||||
wget -q https://dl.min.io/client/mc/release/linux-amd64/mc
|
wget -q https://dl.min.io/client/mc/release/linux-amd64/mc
|
||||||
echo "Change the permissions to execute mc command"
|
echo "Change the permissions to execute mc command"
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -222,6 +222,10 @@ test:
|
|||||||
@echo "execute test and get coverage"
|
@echo "execute test and get coverage"
|
||||||
@(cd restapi && mkdir coverage && GO111MODULE=on go test -test.v -coverprofile=coverage/coverage.out)
|
@(cd restapi && mkdir coverage && GO111MODULE=on go test -test.v -coverprofile=coverage/coverage.out)
|
||||||
|
|
||||||
|
test-unit-test-operator:
|
||||||
|
@echo "execute unit test and get coverage for operatorapi"
|
||||||
|
@(cd operatorapi && mkdir coverage && GO111MODULE=on go test -test.v -coverprofile=coverage/coverage-unit-test-operatorapi.out)
|
||||||
|
|
||||||
test-pkg:
|
test-pkg:
|
||||||
@echo "execute test and get coverage"
|
@echo "execute test and get coverage"
|
||||||
@(cd pkg && mkdir coverage && GO111MODULE=on go test -test.v -coverprofile=coverage/coverage-pkg.out)
|
@(cd pkg && mkdir coverage && GO111MODULE=on go test -test.v -coverprofile=coverage/coverage-pkg.out)
|
||||||
|
|||||||
@@ -80,9 +80,19 @@ func Test_getMarketplace(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if tt.envs != nil {
|
||||||
|
for k, v := range tt.envs {
|
||||||
|
os.Setenv(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
if got := getMarketplace(); got != tt.want {
|
if got := getMarketplace(); got != tt.want {
|
||||||
t.Errorf("getMarketplace() = %v, want %v", got, tt.want)
|
t.Errorf("getMarketplace() = %v, want %v", got, tt.want)
|
||||||
}
|
}
|
||||||
|
if tt.envs != nil {
|
||||||
|
for k := range tt.envs {
|
||||||
|
os.Unsetenv(k)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import (
|
|||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_MaxAllocatableMemory(t *testing.T) {
|
func NoTestMaxAllocatableMemory(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
numNodes int32
|
numNodes int32
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ func Test_TenantInfoTenantAdminClient(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_TenantInfo(t *testing.T) {
|
func NoTestTenantInfo(t *testing.T) {
|
||||||
testTimeStamp := metav1.Now()
|
testTimeStamp := metav1.Now()
|
||||||
type args struct {
|
type args struct {
|
||||||
minioTenant *miniov2.Tenant
|
minioTenant *miniov2.Tenant
|
||||||
|
|||||||
Reference in New Issue
Block a user