Cleanup tests/e2e/common directory - part 1
This commit is contained in:
@@ -8,35 +8,23 @@ load(
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"configmap.go",
|
||||
"configmap_volume.go",
|
||||
"container.go",
|
||||
"container_probe.go",
|
||||
"docker_containers.go",
|
||||
"downward_api.go",
|
||||
"downwardapi_volume.go",
|
||||
"empty_dir.go",
|
||||
"downwardapi.go",
|
||||
"expansion.go",
|
||||
"framework.go",
|
||||
"host_path.go",
|
||||
"imports.go",
|
||||
"init_container.go",
|
||||
"kubelet.go",
|
||||
"kubelet_etc_hosts.go",
|
||||
"lease.go",
|
||||
"lifecycle_hook.go",
|
||||
"networking.go",
|
||||
"node_lease.go",
|
||||
"pods.go",
|
||||
"podtemplates.go",
|
||||
"privileged.go",
|
||||
"projected_combined.go",
|
||||
"projected_configmap.go",
|
||||
"projected_downwardapi.go",
|
||||
"projected_secret.go",
|
||||
"runtime.go",
|
||||
"runtimeclass.go",
|
||||
"secrets.go",
|
||||
"secrets_volume.go",
|
||||
"security_context.go",
|
||||
"sysctl.go",
|
||||
"util.go",
|
||||
@@ -46,14 +34,11 @@ go_library(
|
||||
deps = [
|
||||
"//pkg/api/v1/pod:go_default_library",
|
||||
"//pkg/client/conditions:go_default_library",
|
||||
"//pkg/features:go_default_library",
|
||||
"//pkg/kubelet:go_default_library",
|
||||
"//pkg/kubelet/events:go_default_library",
|
||||
"//pkg/kubelet/images:go_default_library",
|
||||
"//pkg/kubelet/runtimeclass/testing:go_default_library",
|
||||
"//staging/src/k8s.io/api/coordination/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/node/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
@@ -70,11 +55,13 @@ go_library(
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/dynamic:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/tools/watch:go_default_library",
|
||||
"//test/e2e/common/network:go_default_library",
|
||||
"//test/e2e/common/node:go_default_library",
|
||||
"//test/e2e/common/storage:go_default_library",
|
||||
"//test/e2e/framework:go_default_library",
|
||||
"//test/e2e/framework/events:go_default_library",
|
||||
"//test/e2e/framework/network:go_default_library",
|
||||
@@ -104,6 +91,11 @@ filegroup(
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//test/e2e/common/network:all-srcs",
|
||||
"//test/e2e/common/node:all-srcs",
|
||||
"//test/e2e/common/storage:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
24
test/e2e/common/imports.go
Normal file
24
test/e2e/common/imports.go
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2021 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 common
|
||||
|
||||
import (
|
||||
// ensure these packages are scanned by ginkgo for e2e tests
|
||||
_ "k8s.io/kubernetes/test/e2e/common/network"
|
||||
_ "k8s.io/kubernetes/test/e2e/common/node"
|
||||
_ "k8s.io/kubernetes/test/e2e/common/storage"
|
||||
)
|
||||
32
test/e2e/common/network/BUILD
Normal file
32
test/e2e/common/network/BUILD
Normal file
@@ -0,0 +1,32 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"framework.go",
|
||||
"networking.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/test/e2e/common/network",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//test/e2e/framework:go_default_library",
|
||||
"//test/e2e/framework/network:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
4
test/e2e/common/network/OWNERS
Normal file
4
test/e2e/common/network/OWNERS
Normal file
@@ -0,0 +1,4 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
labels:
|
||||
- sig/network
|
||||
24
test/e2e/common/network/framework.go
Normal file
24
test/e2e/common/network/framework.go
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2021 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 network
|
||||
|
||||
import "k8s.io/kubernetes/test/e2e/framework"
|
||||
|
||||
// SIGDescribe annotates the test with the SIG label.
|
||||
func SIGDescribe(text string, body func()) bool {
|
||||
return framework.KubeDescribe("[sig-network] "+text, body)
|
||||
}
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package network
|
||||
|
||||
import (
|
||||
"github.com/onsi/ginkgo"
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
|
||||
)
|
||||
|
||||
var _ = SIGNetworkDescribe("Networking", func() {
|
||||
var _ = SIGDescribe("Networking", func() {
|
||||
f := framework.NewDefaultFramework("pod-network-test")
|
||||
|
||||
ginkgo.Describe("Granular Checks: Pods", func() {
|
||||
46
test/e2e/common/node/BUILD
Normal file
46
test/e2e/common/node/BUILD
Normal file
@@ -0,0 +1,46 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"configmap.go",
|
||||
"framework.go",
|
||||
"podtemplates.go",
|
||||
"runtimeclass.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/test/e2e/common/node",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/kubelet/events:go_default_library",
|
||||
"//pkg/kubelet/runtimeclass/testing:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/node/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//test/e2e/framework:go_default_library",
|
||||
"//test/e2e/framework/events:go_default_library",
|
||||
"//test/e2e/framework/node:go_default_library",
|
||||
"//test/e2e/framework/pod:go_default_library",
|
||||
"//test/utils/image:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
4
test/e2e/common/node/OWNERS
Normal file
4
test/e2e/common/node/OWNERS
Normal file
@@ -0,0 +1,4 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
labels:
|
||||
- sig/node
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
"github.com/onsi/ginkgo"
|
||||
)
|
||||
|
||||
var _ = SIGNodeDescribe("ConfigMap", func() {
|
||||
var _ = SIGDescribe("ConfigMap", func() {
|
||||
f := framework.NewDefaultFramework("configmap")
|
||||
|
||||
/*
|
||||
@@ -238,6 +238,21 @@ var _ = SIGNodeDescribe("ConfigMap", func() {
|
||||
})
|
||||
})
|
||||
|
||||
func newConfigMap(f *framework.Framework, name string) *v1.ConfigMap {
|
||||
return &v1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: f.Namespace.Name,
|
||||
Name: name,
|
||||
},
|
||||
Data: map[string]string{
|
||||
"data-1": "value-1",
|
||||
"data-2": "value-2",
|
||||
"data-3": "value-3",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Unify with newConfigMap
|
||||
func newEnvFromConfigMap(f *framework.Framework, name string) *v1.ConfigMap {
|
||||
return &v1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
24
test/e2e/common/node/framework.go
Normal file
24
test/e2e/common/node/framework.go
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2021 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 node
|
||||
|
||||
import "k8s.io/kubernetes/test/e2e/framework"
|
||||
|
||||
// SIGDescribe annotates the test with the SIG label.
|
||||
func SIGDescribe(text string, body func()) bool {
|
||||
return framework.KubeDescribe("[sig-node] "+text, body)
|
||||
}
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -38,7 +38,7 @@ const (
|
||||
podTemplateRetryTimeout = 1 * time.Minute
|
||||
)
|
||||
|
||||
var _ = SIGNodeDescribe("PodTemplates", func() {
|
||||
var _ = SIGDescribe("PodTemplates", func() {
|
||||
f := framework.NewDefaultFramework("podtemplate")
|
||||
/*
|
||||
Release: v1.19
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -39,7 +39,7 @@ import (
|
||||
"github.com/onsi/ginkgo"
|
||||
)
|
||||
|
||||
var _ = SIGNodeDescribe("RuntimeClass", func() {
|
||||
var _ = SIGDescribe("RuntimeClass", func() {
|
||||
f := framework.NewDefaultFramework("runtimeclass")
|
||||
|
||||
ginkgo.It("should reject a Pod requesting a non-existent RuntimeClass [NodeFeature:RuntimeHandler]", func() {
|
||||
@@ -233,6 +233,21 @@ var _ = ginkgo.Describe("[sig-api-machinery] Secrets", func() {
|
||||
})
|
||||
})
|
||||
|
||||
func secretForTest(namespace, name string) *v1.Secret {
|
||||
return &v1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: namespace,
|
||||
Name: name,
|
||||
},
|
||||
Data: map[string][]byte{
|
||||
"data-1": []byte("value-1\n"),
|
||||
"data-2": []byte("value-2\n"),
|
||||
"data-3": []byte("value-3\n"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Unify with secretForTest.
|
||||
func newEnvFromSecret(namespace, name string) *v1.Secret {
|
||||
return &v1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
||||
49
test/e2e/common/storage/BUILD
Normal file
49
test/e2e/common/storage/BUILD
Normal file
@@ -0,0 +1,49 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"configmap_volume.go",
|
||||
"downwardapi_volume.go",
|
||||
"empty_dir.go",
|
||||
"framework.go",
|
||||
"host_path.go",
|
||||
"projected_combined.go",
|
||||
"projected_configmap.go",
|
||||
"projected_downwardapi.go",
|
||||
"projected_secret.go",
|
||||
"secrets_volume.go",
|
||||
"util.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/test/e2e/common/storage",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/features:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//test/e2e/framework:go_default_library",
|
||||
"//test/e2e/framework/pod:go_default_library",
|
||||
"//test/e2e/framework/skipper:go_default_library",
|
||||
"//test/utils/image:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
4
test/e2e/common/storage/OWNERS
Normal file
4
test/e2e/common/storage/OWNERS
Normal file
@@ -0,0 +1,4 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
labels:
|
||||
- sig/storage
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
)
|
||||
|
||||
var _ = SIGStorageDescribe("ConfigMap", func() {
|
||||
var _ = SIGDescribe("ConfigMap", func() {
|
||||
f := framework.NewDefaultFramework("configmap")
|
||||
|
||||
/*
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = SIGStorageDescribe("Downward API volume", func() {
|
||||
var _ = SIGDescribe("Downward API volume", func() {
|
||||
// How long to wait for a log pod to be displayed
|
||||
const podLogTimeout = 3 * time.Minute
|
||||
f := framework.NewDefaultFramework("downward-api")
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -42,7 +42,7 @@ var (
|
||||
nonRootUID = int64(1001)
|
||||
)
|
||||
|
||||
var _ = SIGStorageDescribe("EmptyDir volumes", func() {
|
||||
var _ = SIGDescribe("EmptyDir volumes", func() {
|
||||
f := framework.NewDefaultFramework("emptydir")
|
||||
|
||||
ginkgo.Context("when FSGroup is specified [LinuxOnly] [NodeFeature:FSGroup]", func() {
|
||||
24
test/e2e/common/storage/framework.go
Normal file
24
test/e2e/common/storage/framework.go
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2021 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 storage
|
||||
|
||||
import "k8s.io/kubernetes/test/e2e/framework"
|
||||
|
||||
// SIGDescribe annotates the test with the SIG label.
|
||||
func SIGDescribe(text string, body func()) bool {
|
||||
return framework.KubeDescribe("[sig-storage] "+text, body)
|
||||
}
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
|
||||
//TODO : Consolidate this code with the code for emptyDir.
|
||||
//This will require some smart.
|
||||
var _ = SIGStorageDescribe("HostPath", func() {
|
||||
var _ = SIGDescribe("HostPath", func() {
|
||||
f := framework.NewDefaultFramework("hostpath")
|
||||
|
||||
ginkgo.BeforeEach(func() {
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
"github.com/onsi/ginkgo"
|
||||
)
|
||||
|
||||
var _ = SIGStorageDescribe("Projected combined", func() {
|
||||
var _ = SIGDescribe("Projected combined", func() {
|
||||
f := framework.NewDefaultFramework("projected")
|
||||
|
||||
// Test multiple projections
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = SIGStorageDescribe("Projected configMap", func() {
|
||||
var _ = SIGDescribe("Projected configMap", func() {
|
||||
f := framework.NewDefaultFramework("projected")
|
||||
|
||||
/*
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = SIGStorageDescribe("Projected downwardAPI", func() {
|
||||
var _ = SIGDescribe("Projected downwardAPI", func() {
|
||||
f := framework.NewDefaultFramework("projected")
|
||||
|
||||
// How long to wait for a log pod to be displayed
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = SIGStorageDescribe("Projected secret", func() {
|
||||
var _ = SIGDescribe("Projected secret", func() {
|
||||
f := framework.NewDefaultFramework("projected")
|
||||
|
||||
/*
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package common
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = SIGStorageDescribe("Secrets", func() {
|
||||
var _ = SIGDescribe("Secrets", func() {
|
||||
f := framework.NewDefaultFramework("secrets")
|
||||
|
||||
/*
|
||||
74
test/e2e/common/storage/util.go
Normal file
74
test/e2e/common/storage/util.go
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright 2016 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 storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
)
|
||||
|
||||
var (
|
||||
// non-Administrator Windows user used in tests. This is the Windows equivalent of the Linux non-root UID usage.
|
||||
nonAdminTestUserName = "ContainerUser"
|
||||
// non-root UID used in tests.
|
||||
nonRootTestUserID = int64(1000)
|
||||
)
|
||||
|
||||
// setPodNonRootUser configures the Pod to run as a non-root user.
|
||||
// For Windows, it sets the RunAsUserName field to ContainerUser, and for Linux, it sets the RunAsUser field to 1000.
|
||||
func setPodNonRootUser(pod *v1.Pod) {
|
||||
if framework.NodeOSDistroIs("windows") {
|
||||
pod.Spec.SecurityContext.WindowsOptions = &v1.WindowsSecurityContextOptions{RunAsUserName: &nonAdminTestUserName}
|
||||
} else {
|
||||
pod.Spec.SecurityContext.RunAsUser = &nonRootTestUserID
|
||||
}
|
||||
}
|
||||
|
||||
// getFileModeRegex returns a file mode related regex which should be matched by the mounttest pods' output.
|
||||
// If the given mask is nil, then the regex will contain the default OS file modes, which are 0644 for Linux and 0775 for Windows.
|
||||
func getFileModeRegex(filePath string, mask *int32) string {
|
||||
var (
|
||||
linuxMask int32
|
||||
windowsMask int32
|
||||
)
|
||||
if mask == nil {
|
||||
linuxMask = int32(0644)
|
||||
windowsMask = int32(0775)
|
||||
} else {
|
||||
linuxMask = *mask
|
||||
windowsMask = *mask
|
||||
}
|
||||
|
||||
linuxOutput := fmt.Sprintf("mode of file \"%s\": %v", filePath, os.FileMode(linuxMask))
|
||||
windowsOutput := fmt.Sprintf("mode of Windows file \"%v\": %s", filePath, os.FileMode(windowsMask))
|
||||
|
||||
return fmt.Sprintf("(%s|%s)", linuxOutput, windowsOutput)
|
||||
}
|
||||
|
||||
// createMounts creates a v1.VolumeMount list with a single element.
|
||||
func createMounts(volumeName, volumeMountPath string, readOnly bool) []v1.VolumeMount {
|
||||
return []v1.VolumeMount{
|
||||
{
|
||||
Name: volumeName,
|
||||
MountPath: volumeMountPath,
|
||||
ReadOnly: readOnly,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
@@ -48,8 +47,6 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// non-Administrator Windows user used in tests. This is the Windows equivalent of the Linux non-root UID usage.
|
||||
nonAdminTestUserName = "ContainerUser"
|
||||
// non-root UID used in tests.
|
||||
nonRootTestUserID = int64(1000)
|
||||
)
|
||||
@@ -212,45 +209,3 @@ func rcByNamePort(name string, replicas int32, image string, containerArgs []str
|
||||
Ports: []v1.ContainerPort{{ContainerPort: int32(port), Protocol: protocol}},
|
||||
}, gracePeriod)
|
||||
}
|
||||
|
||||
// setPodNonRootUser configures the Pod to run as a non-root user.
|
||||
// For Windows, it sets the RunAsUserName field to ContainerUser, and for Linux, it sets the RunAsUser field to 1000.
|
||||
func setPodNonRootUser(pod *v1.Pod) {
|
||||
if framework.NodeOSDistroIs("windows") {
|
||||
pod.Spec.SecurityContext.WindowsOptions = &v1.WindowsSecurityContextOptions{RunAsUserName: &nonAdminTestUserName}
|
||||
} else {
|
||||
pod.Spec.SecurityContext.RunAsUser = &nonRootTestUserID
|
||||
}
|
||||
}
|
||||
|
||||
// getFileModeRegex returns a file mode related regex which should be matched by the mounttest pods' output.
|
||||
// If the given mask is nil, then the regex will contain the default OS file modes, which are 0644 for Linux and 0775 for Windows.
|
||||
func getFileModeRegex(filePath string, mask *int32) string {
|
||||
var (
|
||||
linuxMask int32
|
||||
windowsMask int32
|
||||
)
|
||||
if mask == nil {
|
||||
linuxMask = int32(0644)
|
||||
windowsMask = int32(0775)
|
||||
} else {
|
||||
linuxMask = *mask
|
||||
windowsMask = *mask
|
||||
}
|
||||
|
||||
linuxOutput := fmt.Sprintf("mode of file \"%s\": %v", filePath, os.FileMode(linuxMask))
|
||||
windowsOutput := fmt.Sprintf("mode of Windows file \"%v\": %s", filePath, os.FileMode(windowsMask))
|
||||
|
||||
return fmt.Sprintf("(%s|%s)", linuxOutput, windowsOutput)
|
||||
}
|
||||
|
||||
// createMounts creates a v1.VolumeMount list with a single element.
|
||||
func createMounts(volumeName, volumeMountPath string, readOnly bool) []v1.VolumeMount {
|
||||
return []v1.VolumeMount{
|
||||
{
|
||||
Name: volumeName,
|
||||
MountPath: volumeMountPath,
|
||||
ReadOnly: readOnly,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user