-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test framework. (#10)
* Move logic from cmd/manager to a package for easier testing. Signed-off-by: Anthony Yeh <[email protected]> * Add integration test framework. Signed-off-by: Anthony Yeh <[email protected]> * Add integration-test workflow. Signed-off-by: Anthony Yeh <[email protected]> * integration/framework: Wait for CRDs to be ready. Signed-off-by: Anthony Yeh <[email protected]> * Switch to controller-runtime client. Signed-off-by: Anthony Yeh <[email protected]>
- Loading branch information
Showing
16 changed files
with
801 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: integration-test | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
build: | ||
name: Integration Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.12 | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v1 | ||
|
||
- name: Go module cache | ||
id: go-mod-cache | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: go-mod-cache | ||
|
||
- name: Integration Test | ||
run: make integration-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ jobs: | |
run: go install -v ./... | ||
|
||
- name: Unit Test | ||
run: go test ./... | ||
run: make unit-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package controllermanager | ||
|
||
import ( | ||
"fmt" | ||
|
||
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) | ||
_ "k8s.io/client-go/plugin/pkg/client/auth" | ||
"k8s.io/client-go/rest" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" | ||
|
||
"planetscale.dev/vitess-operator/pkg/controller" | ||
vbssubcontroller "planetscale.dev/vitess-operator/pkg/controller/vitessbackupstorage/subcontroller" | ||
) | ||
|
||
var log = logf.Log.WithName("controller-manager") | ||
|
||
func New(forkPath string, cfg *rest.Config, opts manager.Options) (manager.Manager, error) { | ||
// Set up scheme for all resources we depend on. | ||
var err error | ||
opts.Scheme, err = NewScheme() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Create a new manager to provide shared dependencies and start components | ||
mgr, err := manager.New(cfg, opts) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
log.Info("Registering Components.") | ||
|
||
// We use the fork path primarily to decide which controllers to run in this | ||
// manager process. Not all controllers run in the root process, for example. | ||
switch forkPath { | ||
case "": | ||
// Run all root controllers, defined as anything that registers itself | ||
// in the top-level 'pkg/controller' at package init time. | ||
if err := controller.AddToManager(mgr); err != nil { | ||
return nil, err | ||
} | ||
case vbssubcontroller.ForkPath: | ||
// Run only the vitessbackupstorage subcontroller. | ||
if err := vbssubcontroller.Add(mgr); err != nil { | ||
return nil, err | ||
} | ||
default: | ||
return nil, fmt.Errorf("undefined fork path: %v", forkPath) | ||
} | ||
|
||
return mgr, nil | ||
} |
Oops, something went wrong.