Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f7ae22ab
Commit
f7ae22ab
authored
May 31, 2017
by
Shiyang Wang
Committed by
shiywang
Jun 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
e2e test that ensures that CRDs work in kube-apiserver
parent
0613ae50
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
1 deletion
+86
-1
BUILD
...apiextensions-apiserver/test/integration/testserver/BUILD
+1
-0
resources.go
...nsions-apiserver/test/integration/testserver/resources.go
+21
-1
BUILD
test/e2e/BUILD
+4
-0
custom_resource_definition.go
test/e2e/custom_resource_definition.go
+60
-0
No files found.
staging/src/k8s.io/apiextensions-apiserver/test/integration/testserver/BUILD
View file @
f7ae22ab
...
...
@@ -29,6 +29,7 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authorization/authorizerfactory:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server:go_default_library",
"//vendor/k8s.io/apiserver/pkg/storage/names:go_default_library",
"//vendor/k8s.io/client-go/dynamic:go_default_library",
],
)
staging/src/k8s.io/apiextensions-apiserver/test/integration/testserver/resources.go
View file @
f7ae22ab
...
...
@@ -29,9 +29,29 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apiserver/pkg/storage/names"
"k8s.io/client-go/dynamic"
)
//NewRandomNameCustomResourceDefinition generates a CRD with random name to avoid name conflict in e2e tests
func
NewRandomNameCustomResourceDefinition
(
scope
apiextensionsv1beta1
.
ResourceScope
)
*
apiextensionsv1beta1
.
CustomResourceDefinition
{
gName
:=
names
.
SimpleNameGenerator
.
GenerateName
(
"foo"
)
return
&
apiextensionsv1beta1
.
CustomResourceDefinition
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
gName
+
"s.mygroup.example.com"
},
Spec
:
apiextensionsv1beta1
.
CustomResourceDefinitionSpec
{
Group
:
"mygroup.example.com"
,
Version
:
"v1beta1"
,
Names
:
apiextensionsv1beta1
.
CustomResourceDefinitionNames
{
Plural
:
gName
+
"s"
,
Singular
:
gName
,
Kind
:
gName
,
ListKind
:
gName
+
"List"
,
},
Scope
:
scope
,
},
}
}
func
NewNoxuCustomResourceDefinition
(
scope
apiextensionsv1beta1
.
ResourceScope
)
*
apiextensionsv1beta1
.
CustomResourceDefinition
{
return
&
apiextensionsv1beta1
.
CustomResourceDefinition
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"noxus.mygroup.example.com"
},
...
...
@@ -155,7 +175,7 @@ func CreateNewCustomResourceDefinition(crd *apiextensionsv1beta1.CustomResourceD
// can get a different RV because etcd can be touched in between the initial list operation (if that's what you're doing first)
// and the storage cache reflector starting.
// Later, you can issue a watch with the REST apis list.RV and end up earlier than the storage cacher.
// The general working model is that if you get a "resourceVersion to old" message, you re-list and rewatch.
// The general working model is that if you get a "resourceVersion to
o
old" message, you re-list and rewatch.
// For this test, we'll actually cycle, "list/watch/create/delete" until we get an RV from list that observes the create and not an error.
// This way all the tests that are checking for watches don't have to worry about RV too old problems because crazy things *could* happen
// before like the created RV could be too old to watch.
...
...
test/e2e/BUILD
View file @
f7ae22ab
...
...
@@ -51,6 +51,7 @@ go_library(
"certificates.go",
"cluster_upgrade.go",
"cronjob.go",
"custom_resource_definition.go",
"daemon_restart.go",
"daemon_set.go",
"dashboard.go",
...
...
@@ -183,6 +184,9 @@ go_library(
"//vendor/golang.org/x/net/websocket:go_default_library",
"//vendor/golang.org/x/oauth2/google:go_default_library",
"//vendor/google.golang.org/api/monitoring/v3:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/test/integration/testserver:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
...
...
test/e2e/custom_resource_definition.go
0 → 100644
View file @
f7ae22ab
/*
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
e2e
import
(
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
"k8s.io/apiextensions-apiserver/test/integration/testserver"
"k8s.io/kubernetes/test/e2e/framework"
.
"github.com/onsi/ginkgo"
)
var
_
=
Describe
(
"CustomResourceDefinition resources"
,
func
()
{
f
:=
framework
.
NewDefaultFramework
(
"custom-resource-definition"
)
Context
(
"Simple CustomResourceDefinition"
,
func
()
{
It
(
"creating/deleting custom resource definition objects works [Conformance]"
,
func
()
{
config
,
err
:=
framework
.
LoadConfig
()
if
err
!=
nil
{
framework
.
Failf
(
"failed to load config: %v"
,
err
)
}
apiExtensionClient
,
err
:=
clientset
.
NewForConfig
(
config
)
if
err
!=
nil
{
framework
.
Failf
(
"failed to initialize apiExtensionClient: %v"
,
err
)
}
randomDefinition
:=
testserver
.
NewRandomNameCustomResourceDefinition
(
v1beta1
.
ClusterScoped
)
//create CRD and waits for the resource to be recognized and available.
_
,
err
=
testserver
.
CreateNewCustomResourceDefinition
(
randomDefinition
,
apiExtensionClient
,
f
.
ClientPool
)
if
err
!=
nil
{
framework
.
Failf
(
"failed to create CustomResourceDefinition: %v"
,
err
)
}
defer
func
()
{
err
=
testserver
.
DeleteCustomResourceDefinition
(
randomDefinition
,
apiExtensionClient
)
if
err
!=
nil
{
framework
.
Failf
(
"failed to delete CustomResourceDefinition: %v"
,
err
)
}
}()
})
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment