Skip to content

Commit

Permalink
Tests cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Orive <[email protected]>
  • Loading branch information
Adirio committed Jan 9, 2021
1 parent 26d7b42 commit f500ade
Show file tree
Hide file tree
Showing 19 changed files with 449 additions and 518 deletions.
44 changes: 26 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash

# Copyright 2019 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -61,7 +60,7 @@ generate: generate-testdata ## Update/generate all mock data. You should run thi

.PHONY: generate-testdata
generate-testdata: ## Update/generate the testdata in $GOPATH/src/sigs.k8s.io/kubebuilder
./generate_testdata.sh
./test/testdata/generate.sh

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter
Expand All @@ -80,26 +79,35 @@ golangci-lint:

##@ Tests

.PHONY: go-test
go-test: ## Run the unit test
go test -race -v ./cmd/... ./pkg/... ./plugins/...

.PHONY: test
test: ## Run the unit tests (used in the CI)
./test.sh
test: test-unit test-integration test-testdata ## Run the unit and integration tests (used in the CI)

.PHONY: test-unit
test-unit: ## Run the unit tests
go test -race -v ./pkg/...

.PHONY: test-coverage
test-coverage: ## Run coveralls
# remove all coverage files if exists
- rm -rf *.out
# run the go tests and gen the file coverage-all used to do the integration with coverrals.io
go test -race -failfast -tags=integration -coverprofile=coverage-all.out ./cmd/... ./pkg/... ./plugins/...
test-coverage: ## Run unit tests creating the output to report coverage
- rm -rf *.out # Remove all coverage files if exists
go test -race -failfast -tags=integration -coverprofile=coverage-all.out ./pkg/...

.PHONY: test-e2e-local
test-e2e-local: ## It will run the script to install kind and run e2e tests
## To keep the same kind cluster between test runs, use `SKIP_KIND_CLEANUP=1 make test-e2e-local`
./test_e2e_local.sh
.PHONY: test-integration
test-integration: ## Run the integration tests
./test/integration.sh

.PHONY: check-testdata
check-testdata: ## Run the script to ensure that the testdata is updated
./check_testdata.sh
./test/testdata/check.sh

.PHONY: test-testdata
test-testdata: ## Run the tests of the testdata directory
./test/testdata/test.sh

.PHONY: test-e2e-local
test-e2e-local: ## Run the end-to-end tests locally
## To keep the same kind cluster between test runs, use `SKIP_KIND_CLEANUP=1 make test-e2e-local`
./test/e2e/local.sh

.PHONY: test-e2e-ci
test-e2e-ci: ## Run the end-to-end tests (used in the CI)`
./test/e2e/ci.sh
204 changes: 0 additions & 204 deletions common.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type {{ .Resource.Kind }}Status struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
{{ if not .Resource.Namespaced }} //+kubebuilder:resource:scope=Cluster {{ end }}
{{ if not .Resource.Namespaced }}//+kubebuilder:resource:scope=Cluster{{ end }}
// {{ .Resource.Kind }} is the Schema for the {{ .Resource.Plural }} API
type {{ .Resource.Kind }} struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type {{ .Resource.Kind }}Status struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
{{ if not .Resource.Namespaced }} //+kubebuilder:resource:scope=Cluster {{ end }}
{{ if not .Resource.Namespaced }}//+kubebuilder:resource:scope=Cluster{{ end }}
// {{ .Resource.Kind }} is the Schema for the {{ .Resource.Plural }} API
type {{ .Resource.Kind }} struct {
Expand Down
2 changes: 1 addition & 1 deletion plugins/addon/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var _ reconcile.Reconciler = &{{ .Resource.Kind }}Reconciler{}
// {{ .Resource.Kind }}Reconciler reconciles a {{ .Resource.Kind }} object
type {{ .Resource.Kind }}Reconciler struct {
client.Client
Log logr.Logger
Log logr.Logger
Scheme *runtime.Scheme
declarative.Reconciler
Expand Down
8 changes: 6 additions & 2 deletions plugins/addon/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ type {{.Resource.Kind}}Status struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
{{ if not .Resource.Namespaced }} //+kubebuilder:resource:scope=Cluster {{ end }}
{{- if not .Resource.Namespaced }}
//+kubebuilder:resource:scope=Cluster
{{- end }}
// {{.Resource.Kind}} is the Schema for the {{ .Resource.Plural }} API
type {{.Resource.Kind}} struct {
Expand Down Expand Up @@ -110,7 +112,9 @@ func (o *{{.Resource.Kind}}) SetCommonStatus(s addonv1alpha1.CommonStatus) {
}
//+kubebuilder:object:root=true
{{ if not .Resource.Namespaced }} //+kubebuilder:resource:scope=Cluster {{ end }}
{{- if not .Resource.Namespaced }}
//+kubebuilder:resource:scope=Cluster
{{- end }}
// {{.Resource.Kind}}List contains a list of {{.Resource.Kind}}
type {{.Resource.Kind}}List struct {
Expand Down
Loading

0 comments on commit f500ade

Please sign in to comment.