generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e-framework for kwok with kind
Signed-off-by: wwwnay <[email protected]>
- Loading branch information
Showing
33 changed files
with
1,725 additions
and
260 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"sigs.k8s.io/e2e-framework/pkg/features" | ||
|
||
"sigs.k8s.io/kwok/test/e2e/helper" | ||
) | ||
|
||
// CaseNode creates a feature that tests node creation and deletion | ||
func CaseNode(nodeName string) *features.FeatureBuilder { | ||
node := helper.NewNodeBuilder(nodeName). | ||
Build() | ||
return features.New("Node can be created and deleted"). | ||
Assess("create node", helper.CreateNode(node)). | ||
Assess("delete node", helper.DeleteNode(node)) | ||
} | ||
|
||
// CasePod creates a feature that tests pod creation and deletion | ||
func CasePod(nodeName string, namespace string) *features.FeatureBuilder { | ||
node := helper.NewNodeBuilder(nodeName). | ||
Build() | ||
pod0 := helper.NewPodBuilder("pod0"). | ||
WithNamespace(namespace). | ||
WithNodeName(nodeName). | ||
Build() | ||
pod1 := helper.NewPodBuilder("pod1"). | ||
WithNamespace(namespace). | ||
WithNodeName(nodeName). | ||
WithHostNetwork(true). | ||
Build() | ||
return features.New("Pod can be created and deleted"). | ||
Setup(helper.CreateNode(node)). | ||
Teardown(helper.DeleteNode(node)). | ||
Assess("create pod", helper.CreatePod(pod0)). | ||
Assess("create pod for host network", helper.CreatePod(pod1)). | ||
Assess("delete pod", helper.DeletePod(pod0)). | ||
Assess("delete pod for host network", helper.DeletePod(pod1)) | ||
} |
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,18 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package e2e is a test package for e2e test. | ||
package e2e |
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,85 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package helper | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"runtime" | ||
"strings" | ||
|
||
"sigs.k8s.io/e2e-framework/pkg/env" | ||
"sigs.k8s.io/e2e-framework/pkg/envconf" | ||
|
||
"sigs.k8s.io/kwok/pkg/utils/exec" | ||
) | ||
|
||
// BuildKwokImage builds the kwok image and returns a function that can be used | ||
func BuildKwokImage(rootDir string, image string, builder string) env.Func { | ||
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { | ||
ref := strings.SplitN(image, ":", 2) | ||
if len(ref) != 2 { | ||
return nil, fmt.Errorf("invalid image reference %q", image) | ||
} | ||
ctx = exec.WithStdIO(ctx) | ||
ctx = exec.WithDir(ctx, rootDir) | ||
|
||
err := exec.Exec(ctx, "bash", "./hack/releases.sh", "--bin", "kwok", "--platform", "linux/"+runtime.GOARCH) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = exec.Exec(ctx, "bash", "./images/kwok/build.sh", "--image", ref[0], "--builder", builder, "--version", ref[1], "--platform", "linux/"+runtime.GOARCH) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return ctx, nil | ||
} | ||
} | ||
|
||
// BuildKwokBinary builds the kwok binary and returns a function that can be used | ||
func BuildKwokBinary(rootDir string) env.Func { | ||
return buildBinary(rootDir, "kwok") | ||
} | ||
|
||
// BuildKwokctlBinary builds the kwokctl binary and returns a function that can be used | ||
func BuildKwokctlBinary(rootDir string) env.Func { | ||
return buildBinary(rootDir, "kwokctl") | ||
} | ||
|
||
// buildBinary builds the kwok binary and returns a function that can be used | ||
func buildBinary(rootDir string, binary string) env.Func { | ||
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { | ||
ctx = exec.WithStdIO(ctx) | ||
ctx = exec.WithDir(ctx, rootDir) | ||
|
||
err := exec.Exec(ctx, "bash", "./hack/releases.sh", "--bin", binary, "--platform", runtime.GOOS+"/"+runtime.GOARCH) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return ctx, nil | ||
} | ||
} | ||
|
||
// BinSuffix is the suffix for binaries on Windows | ||
var BinSuffix string | ||
|
||
func init() { | ||
if runtime.GOOS == "windows" { | ||
BinSuffix = ".exe" | ||
} | ||
} |
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,18 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package helper provides tools for e2e test. | ||
package helper |
Oops, something went wrong.