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
954f43a1
Commit
954f43a1
authored
Jan 24, 2019
by
Tim Allclair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate RuntimeClass E2E to typed client
parent
291d0cbd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
24 deletions
+12
-24
BUILD
pkg/kubelet/runtimeclass/testing/BUILD
+0
-1
fake_manager.go
pkg/kubelet/runtimeclass/testing/fake_manager.go
+0
-18
BUILD
test/e2e/framework/BUILD
+1
-0
framework.go
test/e2e/framework/framework.go
+5
-0
runtimeclass.go
test/e2e/node/runtimeclass.go
+6
-5
No files found.
pkg/kubelet/runtimeclass/testing/BUILD
View file @
954f43a1
...
@@ -8,7 +8,6 @@ go_library(
...
@@ -8,7 +8,6 @@ go_library(
deps = [
deps = [
"//pkg/kubelet/runtimeclass:go_default_library",
"//pkg/kubelet/runtimeclass:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
"//staging/src/k8s.io/node-api/pkg/apis/node/v1alpha1:go_default_library",
"//staging/src/k8s.io/node-api/pkg/apis/node/v1alpha1:go_default_library",
"//staging/src/k8s.io/node-api/pkg/client/clientset/versioned:go_default_library",
"//staging/src/k8s.io/node-api/pkg/client/clientset/versioned:go_default_library",
"//staging/src/k8s.io/node-api/pkg/client/clientset/versioned/fake:go_default_library",
"//staging/src/k8s.io/node-api/pkg/client/clientset/versioned/fake:go_default_library",
...
...
pkg/kubelet/runtimeclass/testing/fake_manager.go
View file @
954f43a1
...
@@ -18,7 +18,6 @@ package testing
...
@@ -18,7 +18,6 @@ package testing
import
(
import
(
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/kubernetes/pkg/kubelet/runtimeclass"
"k8s.io/kubernetes/pkg/kubelet/runtimeclass"
nodev1alpha1
"k8s.io/node-api/pkg/apis/node/v1alpha1"
nodev1alpha1
"k8s.io/node-api/pkg/apis/node/v1alpha1"
nodeapiclient
"k8s.io/node-api/pkg/client/clientset/versioned"
nodeapiclient
"k8s.io/node-api/pkg/client/clientset/versioned"
...
@@ -68,20 +67,3 @@ func NewRuntimeClass(name, handler string) *nodev1alpha1.RuntimeClass {
...
@@ -68,20 +67,3 @@ func NewRuntimeClass(name, handler string) *nodev1alpha1.RuntimeClass {
},
},
}
}
}
}
// NewUnstructuredRuntimeClass is a helper to generate an unstructured RuntimeClass resource with
// the given name & handler.
func
NewUnstructuredRuntimeClass
(
name
,
handler
string
)
*
unstructured
.
Unstructured
{
return
&
unstructured
.
Unstructured
{
Object
:
map
[
string
]
interface
{}{
"apiVersion"
:
"node.k8s.io/v1alpha1"
,
"kind"
:
"RuntimeClass"
,
"metadata"
:
map
[
string
]
interface
{}{
"name"
:
name
,
},
"spec"
:
map
[
string
]
interface
{}{
"runtimeHandler"
:
handler
,
},
},
}
}
test/e2e/framework/BUILD
View file @
954f43a1
...
@@ -128,6 +128,7 @@ go_library(
...
@@ -128,6 +128,7 @@ go_library(
"//staging/src/k8s.io/client-go/util/retry:go_default_library",
"//staging/src/k8s.io/client-go/util/retry:go_default_library",
"//staging/src/k8s.io/csi-api/pkg/client/clientset/versioned:go_default_library",
"//staging/src/k8s.io/csi-api/pkg/client/clientset/versioned:go_default_library",
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset:go_default_library",
"//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset:go_default_library",
"//staging/src/k8s.io/node-api/pkg/client/clientset/versioned:go_default_library",
"//test/e2e/framework/ginkgowrapper:go_default_library",
"//test/e2e/framework/ginkgowrapper:go_default_library",
"//test/e2e/framework/metrics:go_default_library",
"//test/e2e/framework/metrics:go_default_library",
"//test/e2e/framework/testfiles:go_default_library",
"//test/e2e/framework/testfiles:go_default_library",
...
...
test/e2e/framework/framework.go
View file @
954f43a1
...
@@ -52,6 +52,7 @@ import (
...
@@ -52,6 +52,7 @@ import (
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/test/e2e/framework/metrics"
"k8s.io/kubernetes/test/e2e/framework/metrics"
testutils
"k8s.io/kubernetes/test/utils"
testutils
"k8s.io/kubernetes/test/utils"
nodeapiclient
"k8s.io/node-api/pkg/client/clientset/versioned"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
...
@@ -78,6 +79,7 @@ type Framework struct {
...
@@ -78,6 +79,7 @@ type Framework struct {
KubemarkExternalClusterClientSet
clientset
.
Interface
KubemarkExternalClusterClientSet
clientset
.
Interface
APIExtensionsClientSet
apiextensionsclient
.
Interface
APIExtensionsClientSet
apiextensionsclient
.
Interface
CSIClientSet
csi
.
Interface
CSIClientSet
csi
.
Interface
NodeAPIClientSet
nodeapiclient
.
Interface
InternalClientset
*
internalclientset
.
Clientset
InternalClientset
*
internalclientset
.
Clientset
AggregatorClient
*
aggregatorclient
.
Clientset
AggregatorClient
*
aggregatorclient
.
Clientset
...
@@ -197,6 +199,9 @@ func (f *Framework) BeforeEach() {
...
@@ -197,6 +199,9 @@ func (f *Framework) BeforeEach() {
jsonConfig
.
ContentType
=
"application/json"
jsonConfig
.
ContentType
=
"application/json"
f
.
CSIClientSet
,
err
=
csi
.
NewForConfig
(
jsonConfig
)
f
.
CSIClientSet
,
err
=
csi
.
NewForConfig
(
jsonConfig
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
// node.k8s.io is also based on CRD
f
.
NodeAPIClientSet
,
err
=
nodeapiclient
.
NewForConfig
(
jsonConfig
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
// create scales getter, set GroupVersion and NegotiatedSerializer to default values
// create scales getter, set GroupVersion and NegotiatedSerializer to default values
// as they are required when creating a REST client.
// as they are required when creating a REST client.
...
...
test/e2e/node/runtimeclass.go
View file @
954f43a1
...
@@ -69,14 +69,15 @@ var _ = SIGDescribe("RuntimeClass [Feature:RuntimeClass]", func() {
...
@@ -69,14 +69,15 @@ var _ = SIGDescribe("RuntimeClass [Feature:RuntimeClass]", func() {
It
(
"should reject a Pod requesting a deleted RuntimeClass"
,
func
()
{
It
(
"should reject a Pod requesting a deleted RuntimeClass"
,
func
()
{
rcName
:=
createRuntimeClass
(
f
,
"delete-me"
,
""
)
rcName
:=
createRuntimeClass
(
f
,
"delete-me"
,
""
)
rcClient
:=
f
.
NodeAPIClientSet
.
NodeV1alpha1
()
.
RuntimeClasses
()
By
(
"Deleting RuntimeClass "
+
rcName
,
func
()
{
By
(
"Deleting RuntimeClass "
+
rcName
,
func
()
{
err
:=
f
.
DynamicClient
.
Resource
(
runtimeClassGVR
)
.
Delete
(
rcName
,
nil
)
err
:=
rcClient
.
Delete
(
rcName
,
nil
)
framework
.
ExpectNoError
(
err
,
"failed to delete RuntimeClass %s"
,
rcName
)
framework
.
ExpectNoError
(
err
,
"failed to delete RuntimeClass %s"
,
rcName
)
By
(
"Waiting for the RuntimeClass to disappear"
)
By
(
"Waiting for the RuntimeClass to disappear"
)
framework
.
ExpectNoError
(
wait
.
PollImmediate
(
framework
.
Poll
,
time
.
Minute
,
func
()
(
bool
,
error
)
{
framework
.
ExpectNoError
(
wait
.
PollImmediate
(
framework
.
Poll
,
time
.
Minute
,
func
()
(
bool
,
error
)
{
_
,
err
:=
f
.
DynamicClient
.
Resource
(
runtimeClassGVR
)
.
Get
(
rcName
,
metav1
.
GetOptions
{})
_
,
err
:=
rcClient
.
Get
(
rcName
,
metav1
.
GetOptions
{})
if
errors
.
IsNotFound
(
err
)
{
if
errors
.
IsNotFound
(
err
)
{
return
true
,
nil
// done
return
true
,
nil
// done
}
}
...
@@ -143,11 +144,11 @@ var _ = SIGDescribe("RuntimeClass [Feature:RuntimeClass]", func() {
...
@@ -143,11 +144,11 @@ var _ = SIGDescribe("RuntimeClass [Feature:RuntimeClass]", func() {
})
})
// createRuntimeClass generates a RuntimeClass with the desired handler and a "namespaced" name,
// createRuntimeClass generates a RuntimeClass with the desired handler and a "namespaced" name,
// synchronously creates it
with the dynamic client, and returns the resulting
name.
// synchronously creates it
, and returns the generated
name.
func
createRuntimeClass
(
f
*
framework
.
Framework
,
name
,
handler
string
)
string
{
func
createRuntimeClass
(
f
*
framework
.
Framework
,
name
,
handler
string
)
string
{
uniqueName
:=
fmt
.
Sprintf
(
"%s-%s"
,
f
.
Namespace
.
Name
,
name
)
uniqueName
:=
fmt
.
Sprintf
(
"%s-%s"
,
f
.
Namespace
.
Name
,
name
)
rc
:=
runtimeclasstest
.
New
Unstructured
RuntimeClass
(
uniqueName
,
handler
)
rc
:=
runtimeclasstest
.
NewRuntimeClass
(
uniqueName
,
handler
)
rc
,
err
:=
f
.
DynamicClient
.
Resource
(
runtimeClassGVR
)
.
Create
(
rc
,
metav1
.
CreateOptions
{}
)
rc
,
err
:=
f
.
NodeAPIClientSet
.
NodeV1alpha1
()
.
RuntimeClasses
()
.
Create
(
rc
)
framework
.
ExpectNoError
(
err
,
"failed to create RuntimeClass resource"
)
framework
.
ExpectNoError
(
err
,
"failed to create RuntimeClass resource"
)
return
rc
.
GetName
()
return
rc
.
GetName
()
}
}
...
...
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