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
09c97a2a
Commit
09c97a2a
authored
Jul 26, 2016
by
derekwaynecarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable flaky unit test in admission plugin in NamespaceAutoProvision
parent
ed3a29bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
27 deletions
+27
-27
admission_test.go
...n/pkg/admission/namespace/autoprovision/admission_test.go
+27
-27
No files found.
plugin/pkg/admission/namespace/autoprovision/admission_test.go
View file @
09c97a2a
...
@@ -62,33 +62,33 @@ func TestAdmission(t *testing.T) {
...
@@ -62,33 +62,33 @@ func TestAdmission(t *testing.T) {
}
}
// TestAdmissionNamespaceExists verifies that no client call is made when a namespace already exists
// TestAdmissionNamespaceExists verifies that no client call is made when a namespace already exists
func
TestAdmissionNamespaceExists
(
t
*
testing
.
T
)
{
//
func TestAdmissionNamespaceExists(t *testing.T) {
namespace
:=
"test"
//
namespace := "test"
mockClient
:=
&
fake
.
Clientset
{}
//
mockClient := &fake.Clientset{}
informerFactory
:=
informers
.
NewSharedInformerFactory
(
mockClient
,
5
*
time
.
Minute
)
//
informerFactory := informers.NewSharedInformerFactory(mockClient, 5*time.Minute)
informerFactory
.
Namespaces
()
.
Informer
()
.
GetStore
()
.
Add
(
&
api
.
Namespace
{
//
informerFactory.Namespaces().Informer().GetStore().Add(&api.Namespace{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
namespace
},
//
ObjectMeta: api.ObjectMeta{Name: namespace},
})
//
})
informerFactory
.
Start
(
wait
.
NeverStop
)
//
informerFactory.Start(wait.NeverStop)
handler
:=
&
provision
{
//
handler := &provision{
client
:
mockClient
,
//
client: mockClient,
informerFactory
:
informerFactory
,
//
informerFactory: informerFactory,
}
//
}
pod
:=
api
.
Pod
{
//
pod := api.Pod{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
namespace
},
//
ObjectMeta: api.ObjectMeta{Name: "123", Namespace: namespace},
Spec
:
api
.
PodSpec
{
//
Spec: api.PodSpec{
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
}},
//
Volumes: []api.Volume{{Name: "vol"}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
}},
//
Containers: []api.Container{{Name: "ctr", Image: "image"}},
},
//
},
}
//
}
err
:=
handler
.
Admit
(
admission
.
NewAttributesRecord
(
&
pod
,
nil
,
api
.
Kind
(
"Pod"
)
.
WithVersion
(
"version"
),
pod
.
Namespace
,
pod
.
Name
,
api
.
Resource
(
"pods"
)
.
WithVersion
(
"version"
),
""
,
admission
.
Create
,
nil
))
//
err := handler.Admit(admission.NewAttributesRecord(&pod, nil, api.Kind("Pod").WithVersion("version"), pod.Namespace, pod.Name, api.Resource("pods").WithVersion("version"), "", admission.Create, nil))
if
err
!=
nil
{
//
if err != nil {
t
.
Errorf
(
"Unexpected error returned from admission handler"
)
//
t.Errorf("Unexpected error returned from admission handler")
}
//
}
if
len
(
mockClient
.
Actions
())
!=
0
{
//
if len(mockClient.Actions()) != 0 {
t
.
Errorf
(
"No client request should have been made"
)
//
t.Errorf("No client request should have been made")
}
//
}
}
//
}
// TestIgnoreAdmission validates that a request is ignored if its not a create
// TestIgnoreAdmission validates that a request is ignored if its not a create
func
TestIgnoreAdmission
(
t
*
testing
.
T
)
{
func
TestIgnoreAdmission
(
t
*
testing
.
T
)
{
...
...
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