Replace godep with dep
This commit is contained in:
parent
1e7489927c
commit
bf5616c65b
14883 changed files with 3937406 additions and 361781 deletions
49
vendor/k8s.io/kubernetes/test/integration/federation/BUILD
generated
vendored
Normal file
49
vendor/k8s.io/kubernetes/test/integration/federation/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "large",
|
||||
srcs = [
|
||||
"api_test.go",
|
||||
"crud_test.go",
|
||||
"main_test.go",
|
||||
],
|
||||
tags = ["integration"],
|
||||
deps = [
|
||||
"//federation/apis/federation/v1beta1:go_default_library",
|
||||
"//federation/pkg/federatedtypes:go_default_library",
|
||||
"//federation/pkg/federatedtypes/crudtester:go_default_library",
|
||||
"//test/integration/federation/framework:go_default_library",
|
||||
"//test/integration/framework:go_default_library",
|
||||
"//vendor/github.com/pborman/uuid:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
"//vendor/k8s.io/api/autoscaling/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/batch/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//test/integration/federation/framework:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
16
vendor/k8s.io/kubernetes/test/integration/federation/OWNERS
generated
vendored
Normal file
16
vendor/k8s.io/kubernetes/test/integration/federation/OWNERS
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
reviewers:
|
||||
- colhom
|
||||
- csbell
|
||||
- irfanurrehman
|
||||
- madhusudancs
|
||||
- marun
|
||||
- mwielgus
|
||||
- nikhiljindal
|
||||
- quinton-hoole
|
||||
- shashidharatd
|
||||
approvers:
|
||||
- csbell
|
||||
- madhusudancs
|
||||
- mwielgus
|
||||
- nikhiljindal
|
||||
- quinton-hoole
|
||||
417
vendor/k8s.io/kubernetes/test/integration/federation/api_test.go
generated
vendored
Normal file
417
vendor/k8s.io/kubernetes/test/integration/federation/api_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,417 @@
|
|||
/*
|
||||
Copyright 2015 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 federation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
autoscaling_v1 "k8s.io/api/autoscaling/v1"
|
||||
batch_v1 "k8s.io/api/batch/v1"
|
||||
"k8s.io/api/core/v1"
|
||||
ext_v1b1 "k8s.io/api/extensions/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
fed_v1b1 "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
||||
"k8s.io/kubernetes/test/integration/federation/framework"
|
||||
)
|
||||
|
||||
// List of group versions that are enabled by default.
|
||||
var enabledGroupVersions = []schema.GroupVersion{
|
||||
fed_v1b1.SchemeGroupVersion,
|
||||
ext_v1b1.SchemeGroupVersion,
|
||||
}
|
||||
|
||||
// List of group versions that are disabled by default.
|
||||
var disabledGroupVersions = []schema.GroupVersion{
|
||||
batch_v1.SchemeGroupVersion,
|
||||
autoscaling_v1.SchemeGroupVersion,
|
||||
}
|
||||
|
||||
type apiTestFunc func(t *testing.T, host string, expectedGroupVersions []schema.GroupVersion)
|
||||
|
||||
func testFederationAPI(t *testing.T, runtimeConfig string, expectedGroupVersions []schema.GroupVersion) {
|
||||
f := &framework.FederationAPIFixture{}
|
||||
if runtimeConfig == "" {
|
||||
f.SetUp(t)
|
||||
} else {
|
||||
runOptions := framework.GetRunOptions()
|
||||
runOptions.APIEnablement.RuntimeConfig.Set(runtimeConfig)
|
||||
f.SetUpWithRunOptions(t, runOptions)
|
||||
}
|
||||
defer f.TearDown(t)
|
||||
|
||||
testCases := map[string]apiTestFunc{
|
||||
"swaggerSpec": testSwaggerSpec,
|
||||
"support": testSupport,
|
||||
"apiGroupList": testAPIGroupList,
|
||||
"apiGroup": testAPIGroup,
|
||||
"apiResourceList": testAPIResourceList,
|
||||
}
|
||||
for testName, testFunc := range testCases {
|
||||
t.Run(testName, func(t *testing.T) {
|
||||
testFunc(t, f.Host, expectedGroupVersions)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Verifies that only default APIs are enabled when no runtime config is set.
|
||||
func TestDefaultRun(t *testing.T) {
|
||||
testFederationAPI(t, "", enabledGroupVersions)
|
||||
}
|
||||
|
||||
// Verifies that all APIs are enabled when runtime config is set to all.
|
||||
func TestRunWithRuntimeConfigAll(t *testing.T) {
|
||||
expectedGroupVersions := enabledGroupVersions
|
||||
expectedGroupVersions = append(enabledGroupVersions, disabledGroupVersions...)
|
||||
testFederationAPI(t, "api/all=true", expectedGroupVersions)
|
||||
}
|
||||
|
||||
func readResponse(serverURL string) ([]byte, error) {
|
||||
response, err := http.Get(serverURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error in fetching %s: %v", serverURL, err)
|
||||
}
|
||||
defer response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("unexpected status: %d for URL: %s, expected status: %d", response.StatusCode, serverURL, http.StatusOK)
|
||||
}
|
||||
contents, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error reading response from %s: %v", serverURL, err)
|
||||
}
|
||||
return contents, nil
|
||||
}
|
||||
|
||||
func testSwaggerSpec(t *testing.T, host string, expectedGroupVersions []schema.GroupVersion) {
|
||||
serverURL := host + "/swaggerapi"
|
||||
_, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func testSupport(t *testing.T, host string, expectedGroupVersions []schema.GroupVersion) {
|
||||
serverURL := host + "/version"
|
||||
_, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func findGroup(groups []metav1.APIGroup, groupName string) *metav1.APIGroup {
|
||||
for _, group := range groups {
|
||||
if group.Name == groupName {
|
||||
return &group
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func testAPIGroupList(t *testing.T, host string, expectedGroupVersions []schema.GroupVersion) {
|
||||
groupVersionForDiscoveryMap := make(map[string]metav1.GroupVersionForDiscovery)
|
||||
for _, groupVersion := range expectedGroupVersions {
|
||||
groupVersionForDiscoveryMap[groupVersion.Group] = metav1.GroupVersionForDiscovery{
|
||||
GroupVersion: groupVersion.String(),
|
||||
Version: groupVersion.Version,
|
||||
}
|
||||
}
|
||||
|
||||
serverURL := host + "/apis"
|
||||
contents, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
var apiGroupList metav1.APIGroupList
|
||||
err = json.Unmarshal(contents, &apiGroupList)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in unmarshalling response from server %s: %v", serverURL, err)
|
||||
}
|
||||
|
||||
assert.Equal(t, len(apiGroupList.Groups), len(expectedGroupVersions), "expected: %v, actual: %v", expectedGroupVersions, apiGroupList.Groups)
|
||||
for _, groupVersion := range expectedGroupVersions {
|
||||
found := findGroup(apiGroupList.Groups, groupVersion.Group)
|
||||
assert.NotNil(t, found)
|
||||
assert.Equal(t, groupVersion.Group, found.Name)
|
||||
assert.Equal(t, 1, len(found.Versions))
|
||||
groupVersionForDiscovery := groupVersionForDiscoveryMap[groupVersion.Group]
|
||||
assert.Equal(t, groupVersionForDiscovery, found.Versions[0])
|
||||
assert.Equal(t, groupVersionForDiscovery, found.PreferredVersion)
|
||||
}
|
||||
}
|
||||
|
||||
func testAPIGroup(t *testing.T, host string, expectedGroupVersions []schema.GroupVersion) {
|
||||
for _, groupVersion := range expectedGroupVersions {
|
||||
serverURL := host + "/apis/" + groupVersion.Group
|
||||
contents, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
var apiGroup metav1.APIGroup
|
||||
err = json.Unmarshal(contents, &apiGroup)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in unmarshalling response from server %s: %v", serverURL, err)
|
||||
}
|
||||
// empty APIVersion for extensions group
|
||||
if groupVersion.Group == "extensions" {
|
||||
assert.Equal(t, "", apiGroup.APIVersion)
|
||||
} else {
|
||||
assert.Equal(t, "v1", apiGroup.APIVersion)
|
||||
}
|
||||
assert.Equal(t, apiGroup.Name, groupVersion.Group)
|
||||
assert.Equal(t, 1, len(apiGroup.Versions))
|
||||
assert.Equal(t, groupVersion.String(), apiGroup.Versions[0].GroupVersion)
|
||||
assert.Equal(t, groupVersion.Version, apiGroup.Versions[0].Version)
|
||||
assert.Equal(t, apiGroup.PreferredVersion, apiGroup.Versions[0])
|
||||
}
|
||||
|
||||
testCoreAPIGroup(t, host)
|
||||
}
|
||||
|
||||
func testCoreAPIGroup(t *testing.T, host string) {
|
||||
serverURL := host + "/api"
|
||||
contents, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
var apiVersions metav1.APIVersions
|
||||
err = json.Unmarshal(contents, &apiVersions)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in unmarshalling response from server %s: %v", serverURL, err)
|
||||
}
|
||||
assert.Equal(t, 1, len(apiVersions.Versions))
|
||||
assert.Equal(t, "v1", apiVersions.Versions[0])
|
||||
assert.NotEmpty(t, apiVersions.ServerAddressByClientCIDRs)
|
||||
}
|
||||
|
||||
func findResource(resources []metav1.APIResource, resourceName string) *metav1.APIResource {
|
||||
for _, resource := range resources {
|
||||
if resource.Name == resourceName {
|
||||
return &resource
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func testAPIResourceList(t *testing.T, host string, expectedGroupVersions []schema.GroupVersion) {
|
||||
testFederationResourceList(t, host)
|
||||
testCoreResourceList(t, host)
|
||||
testExtensionsResourceList(t, host)
|
||||
if contains(expectedGroupVersions, batch_v1.SchemeGroupVersion) {
|
||||
testBatchResourceList(t, host)
|
||||
}
|
||||
if contains(expectedGroupVersions, autoscaling_v1.SchemeGroupVersion) {
|
||||
testAutoscalingResourceList(t, host)
|
||||
}
|
||||
}
|
||||
|
||||
func contains(gvs []schema.GroupVersion, requiredGV schema.GroupVersion) bool {
|
||||
for _, gv := range gvs {
|
||||
if gv.String() == requiredGV.String() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func testFederationResourceList(t *testing.T, host string) {
|
||||
serverURL := host + "/apis/" + fed_v1b1.SchemeGroupVersion.String()
|
||||
contents, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
var apiResourceList metav1.APIResourceList
|
||||
err = json.Unmarshal(contents, &apiResourceList)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in unmarshalling response from server %s: %v", serverURL, err)
|
||||
}
|
||||
assert.Equal(t, "v1", apiResourceList.APIVersion)
|
||||
assert.Equal(t, fed_v1b1.SchemeGroupVersion.String(), apiResourceList.GroupVersion)
|
||||
// Assert that there are exactly 2 resources.
|
||||
assert.Equal(t, 2, len(apiResourceList.APIResources))
|
||||
|
||||
found := findResource(apiResourceList.APIResources, "clusters")
|
||||
assert.NotNil(t, found)
|
||||
assert.False(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "clusters/status")
|
||||
assert.NotNil(t, found)
|
||||
assert.False(t, found.Namespaced)
|
||||
}
|
||||
|
||||
func testCoreResourceList(t *testing.T, host string) {
|
||||
serverURL := host + "/api/" + v1.SchemeGroupVersion.String()
|
||||
contents, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
var apiResourceList metav1.APIResourceList
|
||||
err = json.Unmarshal(contents, &apiResourceList)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in unmarshalling response from server %s: %v", serverURL, err)
|
||||
}
|
||||
assert.Equal(t, "", apiResourceList.APIVersion)
|
||||
assert.Equal(t, v1.SchemeGroupVersion.String(), apiResourceList.GroupVersion)
|
||||
assert.Equal(t, 8, len(apiResourceList.APIResources), "ResourceList: %v", apiResourceList.APIResources)
|
||||
|
||||
// Verify services.
|
||||
found := findResource(apiResourceList.APIResources, "services")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "services/status")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
|
||||
// Verify namespaces.
|
||||
found = findResource(apiResourceList.APIResources, "namespaces")
|
||||
assert.NotNil(t, found)
|
||||
assert.False(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "namespaces/status")
|
||||
assert.NotNil(t, found)
|
||||
assert.False(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "namespaces/finalize")
|
||||
assert.NotNil(t, found)
|
||||
assert.False(t, found.Namespaced)
|
||||
|
||||
// Verify events.
|
||||
found = findResource(apiResourceList.APIResources, "events")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
|
||||
// Verify secrets.
|
||||
found = findResource(apiResourceList.APIResources, "secrets")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
|
||||
// Verify config maps.
|
||||
found = findResource(apiResourceList.APIResources, "configmaps")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
}
|
||||
|
||||
func testExtensionsResourceList(t *testing.T, host string) {
|
||||
serverURL := host + "/apis/" + ext_v1b1.SchemeGroupVersion.String()
|
||||
contents, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
var apiResourceList metav1.APIResourceList
|
||||
err = json.Unmarshal(contents, &apiResourceList)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in unmarshalling response from server %s: %v", serverURL, err)
|
||||
}
|
||||
// empty APIVersion for extensions group
|
||||
assert.Equal(t, "", apiResourceList.APIVersion)
|
||||
assert.Equal(t, ext_v1b1.SchemeGroupVersion.String(), apiResourceList.GroupVersion)
|
||||
// Assert that there are exactly 11 resources.
|
||||
assert.Equal(t, 11, len(apiResourceList.APIResources))
|
||||
|
||||
// Verify replicasets.
|
||||
found := findResource(apiResourceList.APIResources, "replicasets")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "replicasets/status")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "replicasets/scale")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
|
||||
// Verify ingress.
|
||||
found = findResource(apiResourceList.APIResources, "ingresses")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "ingresses/status")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
|
||||
// Verify daemonsets.
|
||||
found = findResource(apiResourceList.APIResources, "daemonsets")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "daemonsets/status")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
|
||||
// Verify deployments.
|
||||
found = findResource(apiResourceList.APIResources, "deployments")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "deployments/status")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "deployments/scale")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "deployments/rollback")
|
||||
}
|
||||
|
||||
func testBatchResourceList(t *testing.T, host string) {
|
||||
serverURL := host + "/apis/" + batch_v1.SchemeGroupVersion.String()
|
||||
contents, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
var apiResourceList metav1.APIResourceList
|
||||
err = json.Unmarshal(contents, &apiResourceList)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in unmarshalling response from server %s: %v", serverURL, err)
|
||||
}
|
||||
// empty APIVersion for extensions group
|
||||
assert.Equal(t, "v1", apiResourceList.APIVersion)
|
||||
assert.Equal(t, batch_v1.SchemeGroupVersion.String(), apiResourceList.GroupVersion)
|
||||
// Assert that there are exactly this number of resources.
|
||||
assert.Equal(t, 2, len(apiResourceList.APIResources))
|
||||
|
||||
// Verify jobs
|
||||
found := findResource(apiResourceList.APIResources, "jobs")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "jobs/status")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
}
|
||||
|
||||
func testAutoscalingResourceList(t *testing.T, host string) {
|
||||
serverURL := host + "/apis/" + autoscaling_v1.SchemeGroupVersion.String()
|
||||
contents, err := readResponse(serverURL)
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
var apiResourceList metav1.APIResourceList
|
||||
err = json.Unmarshal(contents, &apiResourceList)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in unmarshalling response from server %s: %v", serverURL, err)
|
||||
}
|
||||
// empty APIVersion for extensions group
|
||||
assert.Equal(t, "v1", apiResourceList.APIVersion)
|
||||
assert.Equal(t, autoscaling_v1.SchemeGroupVersion.String(), apiResourceList.GroupVersion)
|
||||
// Assert that there are exactly this number of resources.
|
||||
assert.Equal(t, 2, len(apiResourceList.APIResources))
|
||||
|
||||
// Verify hpa
|
||||
found := findResource(apiResourceList.APIResources, "horizontalpodautoscalers")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
found = findResource(apiResourceList.APIResources, "horizontalpodautoscalers/status")
|
||||
assert.NotNil(t, found)
|
||||
assert.True(t, found.Namespaced)
|
||||
}
|
||||
114
vendor/k8s.io/kubernetes/test/integration/federation/crud_test.go
generated
vendored
Normal file
114
vendor/k8s.io/kubernetes/test/integration/federation/crud_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
Copyright 2017 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 federation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/pborman/uuid"
|
||||
|
||||
pkgruntime "k8s.io/apimachinery/pkg/runtime"
|
||||
federationapi "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
||||
"k8s.io/kubernetes/federation/pkg/federatedtypes"
|
||||
"k8s.io/kubernetes/federation/pkg/federatedtypes/crudtester"
|
||||
"k8s.io/kubernetes/test/integration/federation/framework"
|
||||
)
|
||||
|
||||
// TestFederationCRUD validates create/read/update/delete operations for federated resource types.
|
||||
func TestFederationCRUD(t *testing.T) {
|
||||
fedFixture := framework.FederationFixture{DesiredClusterCount: 2}
|
||||
fedFixture.SetUp(t)
|
||||
defer fedFixture.TearDown(t)
|
||||
|
||||
federatedTypes := federatedtypes.FederatedTypes()
|
||||
for kind, fedType := range federatedTypes {
|
||||
t.Run(kind, func(t *testing.T) {
|
||||
fixture, crudTester, obj, _ := initCRUDTest(t, &fedFixture, fedType.AdapterFactory, kind)
|
||||
defer fixture.TearDown(t)
|
||||
|
||||
crudTester.CheckLifecycle(obj)
|
||||
})
|
||||
}
|
||||
|
||||
// The following tests target a single type since the underlying logic is common across all types.
|
||||
kind := federatedtypes.SecretKind
|
||||
adapterFactory := federatedtypes.NewSecretAdapter
|
||||
|
||||
// Validate deletion handling where orphanDependents is true or nil
|
||||
orphanedDependents := true
|
||||
testCases := map[string]*bool{
|
||||
"Resource should not be deleted from underlying clusters when OrphanDependents is true": &orphanedDependents,
|
||||
"Resource should not be deleted from underlying clusters when OrphanDependents is nil": nil,
|
||||
}
|
||||
for testName, orphanDependents := range testCases {
|
||||
t.Run(testName, func(t *testing.T) {
|
||||
fixture, crudTester, obj, _ := initCRUDTest(t, &fedFixture, adapterFactory, kind)
|
||||
defer fixture.TearDown(t)
|
||||
|
||||
updatedObj := crudTester.CheckCreate(obj)
|
||||
crudTester.CheckDelete(updatedObj, orphanDependents)
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("Resource should be propagated to a newly added cluster", func(t *testing.T) {
|
||||
fixture, crudTester, obj, _ := initCRUDTest(t, &fedFixture, adapterFactory, kind)
|
||||
defer fixture.TearDown(t)
|
||||
|
||||
updatedObj := crudTester.CheckCreate(obj)
|
||||
// Start a new cluster and validate that the resource is propagated to it.
|
||||
fedFixture.StartCluster(t)
|
||||
// Check propagation to the new cluster by providing the updated set of clients
|
||||
objectExpected := true
|
||||
crudTester.CheckPropagationForClients(updatedObj, fedFixture.ClusterClients, objectExpected)
|
||||
})
|
||||
|
||||
t.Run("Resource should only be propagated to the cluster with a matching selector", func(t *testing.T) {
|
||||
fixture, crudTester, obj, adapter := initCRUDTest(t, &fedFixture, adapterFactory, kind)
|
||||
defer fixture.TearDown(t)
|
||||
|
||||
// Set an annotation to specify that the object is isolated to cluster 1.
|
||||
federatedtypes.SetAnnotation(adapter, obj, federationapi.FederationClusterSelectorAnnotation, `[{"key": "cluster", "operator": "==", "values": ["1"]}]`)
|
||||
|
||||
updatedObj := crudTester.Create(obj)
|
||||
|
||||
// Check propagation to the first cluster
|
||||
objectExpected := true
|
||||
crudTester.CheckPropagationForClients(updatedObj, fedFixture.ClusterClients[0:1], objectExpected)
|
||||
|
||||
// Verify the object is not sent to the second cluster
|
||||
objectExpected = false
|
||||
crudTester.CheckPropagationForClients(updatedObj, fedFixture.ClusterClients[1:2], objectExpected)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// initCRUDTest initializes common elements of a crud test
|
||||
func initCRUDTest(t *testing.T, fedFixture *framework.FederationFixture, adapterFactory federatedtypes.AdapterFactory, kind string) (
|
||||
*framework.ControllerFixture, *crudtester.FederatedTypeCRUDTester, pkgruntime.Object, federatedtypes.FederatedTypeAdapter) {
|
||||
config := fedFixture.APIFixture.NewConfig()
|
||||
fixture := framework.NewControllerFixture(t, kind, adapterFactory, config)
|
||||
|
||||
client := fedFixture.APIFixture.NewClient(fmt.Sprintf("crud-test-%s", kind))
|
||||
adapter := adapterFactory(client, config, nil)
|
||||
|
||||
crudTester := framework.NewFederatedTypeCRUDTester(t, adapter, fedFixture.ClusterClients)
|
||||
|
||||
obj := adapter.NewTestObject(uuid.New())
|
||||
|
||||
return fixture, crudTester, obj, adapter
|
||||
}
|
||||
48
vendor/k8s.io/kubernetes/test/integration/federation/framework/BUILD
generated
vendored
Normal file
48
vendor/k8s.io/kubernetes/test/integration/federation/framework/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"api.go",
|
||||
"controller.go",
|
||||
"crudtester.go",
|
||||
"federation.go",
|
||||
"util.go",
|
||||
],
|
||||
deps = [
|
||||
"//federation/apis/federation/v1beta1:go_default_library",
|
||||
"//federation/client/clientset_generated/federation_clientset:go_default_library",
|
||||
"//federation/cmd/federation-apiserver/app:go_default_library",
|
||||
"//federation/cmd/federation-apiserver/app/options:go_default_library",
|
||||
"//federation/pkg/federatedtypes:go_default_library",
|
||||
"//federation/pkg/federatedtypes/crudtester:go_default_library",
|
||||
"//federation/pkg/federation-controller/cluster:go_default_library",
|
||||
"//federation/pkg/federation-controller/sync:go_default_library",
|
||||
"//pkg/master:go_default_library",
|
||||
"//test/e2e_node/services:go_default_library",
|
||||
"//test/integration/framework:go_default_library",
|
||||
"//vendor/github.com/pborman/uuid:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
133
vendor/k8s.io/kubernetes/test/integration/federation/framework/api.go
generated
vendored
Normal file
133
vendor/k8s.io/kubernetes/test/integration/federation/framework/api.go
generated
vendored
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
Copyright 2017 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 framework
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/pborman/uuid"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
federationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_clientset"
|
||||
"k8s.io/kubernetes/federation/cmd/federation-apiserver/app"
|
||||
"k8s.io/kubernetes/federation/cmd/federation-apiserver/app/options"
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
)
|
||||
|
||||
const apiNoun = "federation apiserver"
|
||||
|
||||
// GetRunOptions returns the default run options that can be used to run a test federation apiserver.
|
||||
func GetRunOptions() *options.ServerRunOptions {
|
||||
r := options.NewServerRunOptions()
|
||||
r.Etcd.StorageConfig.ServerList = []string{framework.GetEtcdURL()}
|
||||
// Use a unique prefix to ensure isolation from other tests using the same etcd instance
|
||||
r.Etcd.StorageConfig.Prefix = uuid.New()
|
||||
// Disable secure serving
|
||||
r.SecureServing.BindPort = 0
|
||||
return r
|
||||
}
|
||||
|
||||
// FederationAPIFixture manages a federation api server
|
||||
type FederationAPIFixture struct {
|
||||
Host string
|
||||
stopChan chan struct{}
|
||||
}
|
||||
|
||||
// SetUp runs federation apiserver with default run options.
|
||||
func (f *FederationAPIFixture) SetUp(t *testing.T) {
|
||||
f.SetUpWithRunOptions(t, GetRunOptions())
|
||||
}
|
||||
|
||||
// SetUpWithRunOptions runs federation apiserver with the given run options.
|
||||
// Uses default run options if runOptions is nil.
|
||||
func (f *FederationAPIFixture) SetUpWithRunOptions(t *testing.T, runOptions *options.ServerRunOptions) {
|
||||
if f.stopChan != nil {
|
||||
t.Fatal("SetUp() already called")
|
||||
}
|
||||
defer TearDownOnPanic(t, f)
|
||||
|
||||
f.stopChan = make(chan struct{})
|
||||
|
||||
err := startServer(t, runOptions, f.stopChan)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
f.Host = fmt.Sprintf("http://%s:%d", runOptions.InsecureServing.BindAddress, runOptions.InsecureServing.BindPort)
|
||||
|
||||
err = waitForServer(t, f.Host)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FederationAPIFixture) TearDown(t *testing.T) {
|
||||
if f.stopChan != nil {
|
||||
close(f.stopChan)
|
||||
f.stopChan = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FederationAPIFixture) NewConfig() *restclient.Config {
|
||||
return &restclient.Config{Host: f.Host}
|
||||
}
|
||||
|
||||
func (f *FederationAPIFixture) NewClient(userAgent string) federationclientset.Interface {
|
||||
config := f.NewConfig()
|
||||
restclient.AddUserAgent(config, userAgent)
|
||||
return federationclientset.NewForConfigOrDie(config)
|
||||
}
|
||||
|
||||
func startServer(t *testing.T, runOptions *options.ServerRunOptions, stopChan <-chan struct{}) error {
|
||||
err := wait.PollImmediate(DefaultWaitInterval, wait.ForeverTestTimeout, func() (bool, error) {
|
||||
port, err := framework.FindFreeLocalPort()
|
||||
if err != nil {
|
||||
t.Logf("Error allocating an ephemeral port: %v", err)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
runOptions.InsecureServing.BindPort = port
|
||||
err = app.NonBlockingRun(runOptions, stopChan)
|
||||
if err != nil {
|
||||
t.Logf("Error starting the %s: %v", apiNoun, err)
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Timed out waiting for the %s: %v", apiNoun, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func waitForServer(t *testing.T, host string) error {
|
||||
err := wait.PollImmediate(DefaultWaitInterval, wait.ForeverTestTimeout, func() (bool, error) {
|
||||
_, err := http.Get(host)
|
||||
if err != nil {
|
||||
t.Logf("Error when trying to contact the API: %v", err)
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Timed out waiting for the %s: %v", apiNoun, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
43
vendor/k8s.io/kubernetes/test/integration/federation/framework/controller.go
generated
vendored
Normal file
43
vendor/k8s.io/kubernetes/test/integration/federation/framework/controller.go
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
Copyright 2017 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 framework
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/kubernetes/federation/pkg/federatedtypes"
|
||||
synccontroller "k8s.io/kubernetes/federation/pkg/federation-controller/sync"
|
||||
)
|
||||
|
||||
// ControllerFixture manages a federation controller for testing.
|
||||
type ControllerFixture struct {
|
||||
stopChan chan struct{}
|
||||
}
|
||||
|
||||
// NewControllerFixture initializes a new controller fixture
|
||||
func NewControllerFixture(t *testing.T, kind string, adapterFactory federatedtypes.AdapterFactory, config *restclient.Config) *ControllerFixture {
|
||||
f := &ControllerFixture{
|
||||
stopChan: make(chan struct{}),
|
||||
}
|
||||
synccontroller.StartFederationSyncController(kind, adapterFactory, config, f.stopChan, true, nil)
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *ControllerFixture) TearDown(t *testing.T) {
|
||||
close(f.stopChan)
|
||||
}
|
||||
47
vendor/k8s.io/kubernetes/test/integration/federation/framework/crudtester.go
generated
vendored
Normal file
47
vendor/k8s.io/kubernetes/test/integration/federation/framework/crudtester.go
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright 2017 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 framework
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/kubernetes/federation/pkg/federatedtypes"
|
||||
"k8s.io/kubernetes/federation/pkg/federatedtypes/crudtester"
|
||||
)
|
||||
|
||||
type IntegrationLogger struct {
|
||||
t *testing.T
|
||||
}
|
||||
|
||||
func (l *IntegrationLogger) Logf(format string, args ...interface{}) {
|
||||
l.t.Logf(format, args...)
|
||||
}
|
||||
|
||||
func (l *IntegrationLogger) Fatalf(format string, args ...interface{}) {
|
||||
l.t.Fatalf(format, args...)
|
||||
}
|
||||
|
||||
func (l *IntegrationLogger) Fatal(msg string) {
|
||||
l.t.Fatal(msg)
|
||||
}
|
||||
|
||||
func NewFederatedTypeCRUDTester(t *testing.T, adapter federatedtypes.FederatedTypeAdapter, clusterClients []clientset.Interface) *crudtester.FederatedTypeCRUDTester {
|
||||
logger := &IntegrationLogger{t}
|
||||
return crudtester.NewFederatedTypeCRUDTester(logger, adapter, clusterClients, DefaultWaitInterval, wait.ForeverTestTimeout)
|
||||
}
|
||||
141
vendor/k8s.io/kubernetes/test/integration/federation/framework/federation.go
generated
vendored
Normal file
141
vendor/k8s.io/kubernetes/test/integration/federation/framework/federation.go
generated
vendored
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
Copyright 2017 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 framework
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
federationapi "k8s.io/kubernetes/federation/apis/federation/v1beta1"
|
||||
federationclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_clientset"
|
||||
clustercontroller "k8s.io/kubernetes/federation/pkg/federation-controller/cluster"
|
||||
"k8s.io/kubernetes/pkg/master"
|
||||
"k8s.io/kubernetes/test/e2e_node/services"
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
)
|
||||
|
||||
type MemberCluster struct {
|
||||
CloseFn framework.CloseFunc
|
||||
Config *master.Config
|
||||
Client clientset.Interface
|
||||
Host string
|
||||
namespaceController *services.NamespaceController
|
||||
}
|
||||
|
||||
// FederationFixture manages a federation api server and a set of member clusters
|
||||
type FederationFixture struct {
|
||||
APIFixture *FederationAPIFixture
|
||||
DesiredClusterCount int
|
||||
Clusters []*MemberCluster
|
||||
|
||||
ClusterClients []clientset.Interface
|
||||
ClusterController *clustercontroller.ClusterController
|
||||
fedClient federationclientset.Interface
|
||||
stopChan chan struct{}
|
||||
}
|
||||
|
||||
func (f *FederationFixture) SetUp(t *testing.T) {
|
||||
if f.APIFixture != nil {
|
||||
t.Fatal("Fixture already started")
|
||||
}
|
||||
if f.DesiredClusterCount < 1 {
|
||||
f.DesiredClusterCount = 1
|
||||
}
|
||||
defer TearDownOnPanic(t, f)
|
||||
|
||||
t.Logf("Starting a federation of %d clusters", f.DesiredClusterCount)
|
||||
|
||||
f.APIFixture = &FederationAPIFixture{}
|
||||
runOptions := GetRunOptions()
|
||||
// Enable all apis features for test.
|
||||
runOptions.APIEnablement.RuntimeConfig.Set("api/all=true")
|
||||
f.APIFixture.SetUpWithRunOptions(t, runOptions)
|
||||
|
||||
f.stopChan = make(chan struct{})
|
||||
monitorPeriod := 1 * time.Second
|
||||
clustercontroller.StartClusterController(f.APIFixture.NewConfig(), f.stopChan, monitorPeriod)
|
||||
|
||||
f.fedClient = f.APIFixture.NewClient("federation-fixture")
|
||||
for i := 0; i < f.DesiredClusterCount; i++ {
|
||||
f.StartCluster(t)
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FederationFixture) StartCluster(t *testing.T) {
|
||||
config := framework.NewMasterConfig()
|
||||
_, _, closeFn := framework.RunAMaster(config)
|
||||
host := config.GenericConfig.LoopbackClientConfig.Host
|
||||
|
||||
clusterClient := clientset.NewForConfigOrDie(config.GenericConfig.LoopbackClientConfig)
|
||||
f.ClusterClients = append(f.ClusterClients, clusterClient)
|
||||
memberCluster := &MemberCluster{
|
||||
CloseFn: closeFn,
|
||||
Config: config,
|
||||
Client: clusterClient,
|
||||
Host: host,
|
||||
namespaceController: services.NewNamespaceController(host),
|
||||
}
|
||||
f.Clusters = append(f.Clusters, memberCluster)
|
||||
err := memberCluster.namespaceController.Start()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
clusterId := len(f.ClusterClients)
|
||||
|
||||
t.Logf("Federated cluster %d serving on %s", clusterId, host)
|
||||
|
||||
cluster := &federationapi.Cluster{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fmt.Sprintf("cluster-%d", clusterId),
|
||||
Labels: map[string]string{"cluster": fmt.Sprintf("%d", clusterId)},
|
||||
},
|
||||
Spec: federationapi.ClusterSpec{
|
||||
ServerAddressByClientCIDRs: []federationapi.ServerAddressByClientCIDR{
|
||||
{
|
||||
ClientCIDR: "0.0.0.0/0",
|
||||
ServerAddress: host,
|
||||
},
|
||||
},
|
||||
// Use insecure access
|
||||
SecretRef: nil,
|
||||
},
|
||||
}
|
||||
f.fedClient.FederationV1beta1().Clusters().Create(cluster)
|
||||
}
|
||||
|
||||
func (f *FederationFixture) TearDown(t *testing.T) {
|
||||
if f.stopChan != nil {
|
||||
close(f.stopChan)
|
||||
f.stopChan = nil
|
||||
}
|
||||
for _, cluster := range f.Clusters {
|
||||
// Need to close controllers with active connections to the
|
||||
// cluster api before stopping the api or the connections will
|
||||
// hang until tcp timeout.
|
||||
cluster.namespaceController.Stop()
|
||||
cluster.CloseFn()
|
||||
}
|
||||
f.Clusters = nil
|
||||
if f.APIFixture != nil {
|
||||
f.APIFixture.TearDown(t)
|
||||
f.APIFixture = nil
|
||||
}
|
||||
}
|
||||
40
vendor/k8s.io/kubernetes/test/integration/federation/framework/util.go
generated
vendored
Normal file
40
vendor/k8s.io/kubernetes/test/integration/federation/framework/util.go
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Copyright 2017 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 framework
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultWaitInterval = 50 * time.Millisecond
|
||||
)
|
||||
|
||||
// SetUp is likely to be fixture-specific, but TearDown needs to be
|
||||
// consistent to enable TearDownOnPanic.
|
||||
type TestFixture interface {
|
||||
TearDown(t *testing.T)
|
||||
}
|
||||
|
||||
// TearDownOnPanic can be used to ensure cleanup on setup failure.
|
||||
func TearDownOnPanic(t *testing.T, f TestFixture) {
|
||||
if r := recover(); r != nil {
|
||||
f.TearDown(t)
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
27
vendor/k8s.io/kubernetes/test/integration/federation/main_test.go
generated
vendored
Normal file
27
vendor/k8s.io/kubernetes/test/integration/federation/main_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Copyright 2017 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 federation
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
framework.EtcdMain(m.Run)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue