-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from jaypipes/multi-kind
add ability to pass a KinD config to fixture
- Loading branch information
Showing
9 changed files
with
207 additions
and
30 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
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,65 @@ | ||
// Use and distribution licensed under the Apache license version 2. | ||
// | ||
// See the COPYING file in the root project directory for full text. | ||
|
||
package kind_test | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/gdt-dev/gdt" | ||
gdtcontext "github.com/gdt-dev/gdt/context" | ||
kindfix "github.com/gdt-dev/kube/fixtures/kind" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDefaultSingleControlPlane(t *testing.T) { | ||
skipKind(t) | ||
require := require.New(t) | ||
|
||
fp := filepath.Join("testdata", "default-single-control-plane.yaml") | ||
|
||
s, err := gdt.From(fp) | ||
require.Nil(err) | ||
require.NotNil(s) | ||
|
||
ctx := gdtcontext.New() | ||
ctx = gdtcontext.RegisterFixture(ctx, "kind", kindfix.New()) | ||
|
||
err = s.Run(ctx, t) | ||
require.Nil(err) | ||
} | ||
|
||
func TestOneControlPlaneOneWorker(t *testing.T) { | ||
skipKind(t) | ||
require := require.New(t) | ||
|
||
fp := filepath.Join("testdata", "one-control-plane-one-worker.yaml") | ||
|
||
s, err := gdt.From(fp) | ||
require.Nil(err) | ||
require.NotNil(s) | ||
|
||
kindCfgPath := filepath.Join("testdata", "kind-config-one-cp-one-worker.yaml") | ||
|
||
ctx := gdtcontext.New() | ||
ctx = gdtcontext.RegisterFixture( | ||
ctx, "kind-one-cp-one-worker", | ||
kindfix.New( | ||
kindfix.WithClusterName("kind-one-cp-one-worker"), | ||
kindfix.WithConfigPath(kindCfgPath), | ||
), | ||
) | ||
|
||
err = s.Run(ctx, t) | ||
require.Nil(err) | ||
} | ||
|
||
func skipKind(t *testing.T) { | ||
_, found := os.LookupEnv("SKIP_KIND") | ||
if found { | ||
t.Skipf("skipping KinD-requiring 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: default-single-control-plane | ||
description: test default KinD cluster has a single control plane node | ||
fixtures: | ||
- kind | ||
tests: | ||
- name: list-all-nodes | ||
kube.get: nodes | ||
assert: | ||
len: 1 | ||
- name: single-control-plane-node | ||
kube: | ||
get: | ||
type: nodes | ||
labels: | ||
node-role.kubernetes.io/control-plane: "" | ||
assert: | ||
len: 1 |
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,7 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
- role: worker | ||
labels: | ||
role: worker |
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,25 @@ | ||
name: one-control-plane-one-worker | ||
description: test default KinD cluster has one control plane node and one worker | ||
fixtures: | ||
- kind-one-cp-one-worker | ||
tests: | ||
- name: list-all-nodes | ||
kube.get: nodes | ||
assert: | ||
len: 2 | ||
- name: one-control-plane-node | ||
kube: | ||
get: | ||
type: nodes | ||
labels: | ||
node-role.kubernetes.io/control-plane: "" | ||
assert: | ||
len: 1 | ||
- name: one-worker-node | ||
kube: | ||
get: | ||
type: nodes | ||
labels: | ||
role: worker | ||
assert: | ||
len: 1 |