Skip to content

Commit

Permalink
chore(test): tidy test scripts in makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI committed Dec 25, 2024
1 parent 5c67edf commit fc5eed0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ jobs:
args: --verbose --timeout=10m --max-same-issues=30
only-new-issues: true
skip-cache: true
- name: make test
run: make test
18 changes: 18 additions & 0 deletions api/v1alpha1/obtenant_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ See the Mulan PSL v2 for more details.
package v1alpha1

import (
oceanbaseconst "github.com/oceanbase/ob-operator/internal/const/oceanbase"

Check failure on line 16 in api/v1alpha1/obtenant_webhook_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/oceanbase/ob-operator (goimports)
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

Expand Down Expand Up @@ -165,4 +166,21 @@ var _ = Describe("Test OBTenant Webhook", Label("webhook"), Serial, func() {

Expect(k8sClient.Create(ctx, t2)).ShouldNot(Succeed())
})

It("Check validating delete webhook", func() {
clusterName := clusterName + "-test-deletion-validate"
cluster := newOBCluster(clusterName, 1, 1)
cluster.Annotations = map[string]string{
oceanbaseconst.AnnotationsIgnoreDeletion: "true",
}
Expect(k8sClient.Create(ctx, cluster)).Should(Succeed())
Expect(k8sClient.Delete(ctx, cluster)).ShouldNot(Succeed())
tenantName := tenantName + "-test-deletion-validate"
t := newOBTenant(tenantName, clusterName)
t.Annotations = map[string]string{
oceanbaseconst.AnnotationsIgnoreDeletion: "true",
}
Expect(k8sClient.Create(ctx, t)).Should(Succeed())
Expect(k8sClient.Delete(ctx, t)).ShouldNot(Succeed())
})
})
30 changes: 16 additions & 14 deletions make/development.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,26 @@ vet: ## Run go vet against code.

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
TEST_USE_EXISTING_CLUSTER=true TELEMETRY_REPORT_HOST=http://openwebapi.test.alipay.net \
DISABLE_TELEMETRY=true LOG_VERBOSITY=0 \
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
go run github.com/onsi/ginkgo/v2/ginkgo -r --covermode=atomic --coverprofile=cover.profile --cpuprofile=cpu.profile --memprofile=mem.profile --cover \
--output-dir=testreports --keep-going --json-report=report.json --label-filter='!long-run' --skip-package './distribution'

.PHONY: test-all
test-all: manifests generate fmt vet envtest ## Run all tests including long-run ones.
TEST_USE_EXISTING_CLUSTER=true TELEMETRY_REPORT_HOST=http://openwebapi.test.alipay.net \
DISABLE_TELEMETRY=true LOG_VERBOSITY=0 \
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
go run github.com/onsi/ginkgo/v2/ginkgo -r --covermode=atomic --coverprofile=cover.profile --cpuprofile=cpu.profile --memprofile=mem.profile --cover \
--output-dir=testreports --keep-going --json-report=report.json --label-filter='$(CASE_LABEL_FILTERS)' --skip-package './distribution'
@make test-webhooks;
@make test-package;
@make test-internal;

.PHONY: test-webhooks
test-webhooks: ## Test the webhooks
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
go run github.com/onsi/ginkgo/v2/ginkgo ./api/...
go test -v ./api/...

.PHONY: test-package
test-package:
go test -v ./pkg/...

.PHONY: test-internal
test-internal:
go test -v ./internal/cli/... \
./internal/clients/... \
./internal/cmds/... \
./internal/config/... \
./internal/telemetry/...

REPORT_PORT ?= 8480

Expand Down

0 comments on commit fc5eed0

Please sign in to comment.