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
8e22dc06
Commit
8e22dc06
authored
May 12, 2017
by
Maru Newby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fed: Factor common setup for crud testing into helper function
parent
ee5dbf10
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
27 deletions
+28
-27
BUILD
test/integration/federation/BUILD
+2
-0
crud_test.go
test/integration/federation/crud_test.go
+26
-27
No files found.
test/integration/federation/BUILD
View file @
8e22dc06
...
@@ -20,6 +20,7 @@ go_test(
...
@@ -20,6 +20,7 @@ go_test(
deps = [
deps = [
"//federation/apis/federation/v1beta1:go_default_library",
"//federation/apis/federation/v1beta1:go_default_library",
"//federation/pkg/federatedtypes:go_default_library",
"//federation/pkg/federatedtypes:go_default_library",
"//federation/pkg/federatedtypes/crudtester:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/apis/autoscaling/v1:go_default_library",
"//pkg/apis/autoscaling/v1:go_default_library",
"//pkg/apis/batch/v1:go_default_library",
"//pkg/apis/batch/v1:go_default_library",
...
@@ -28,6 +29,7 @@ go_test(
...
@@ -28,6 +29,7 @@ go_test(
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1: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",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
],
],
)
)
...
...
test/integration/federation/crud_test.go
View file @
8e22dc06
...
@@ -22,7 +22,9 @@ import (
...
@@ -22,7 +22,9 @@ import (
"github.com/pborman/uuid"
"github.com/pborman/uuid"
pkgruntime
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/federation/pkg/federatedtypes"
"k8s.io/kubernetes/federation/pkg/federatedtypes"
"k8s.io/kubernetes/federation/pkg/federatedtypes/crudtester"
"k8s.io/kubernetes/test/integration/federation/framework"
"k8s.io/kubernetes/test/integration/federation/framework"
)
)
...
@@ -35,16 +37,10 @@ func TestFederationCRUD(t *testing.T) {
...
@@ -35,16 +37,10 @@ func TestFederationCRUD(t *testing.T) {
federatedTypes
:=
federatedtypes
.
FederatedTypes
()
federatedTypes
:=
federatedtypes
.
FederatedTypes
()
for
kind
,
fedType
:=
range
federatedTypes
{
for
kind
,
fedType
:=
range
federatedTypes
{
t
.
Run
(
kind
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
kind
,
func
(
t
*
testing
.
T
)
{
config
:=
fedFixture
.
APIFixture
.
NewConfig
()
fixture
,
crudTester
,
obj
:=
initCRUDTest
(
t
,
&
fedFixture
,
fedType
.
AdapterFactory
,
kind
)
fixture
:=
framework
.
NewControllerFixture
(
t
,
kind
,
fedType
.
AdapterFactory
,
config
)
defer
fixture
.
TearDown
(
t
)
defer
fixture
.
TearDown
(
t
)
client
:=
fedFixture
.
APIFixture
.
NewClient
(
fmt
.
Sprintf
(
"crud-test-%s"
,
kind
))
crudTester
.
CheckLifecycle
(
obj
)
adapter
:=
fedType
.
AdapterFactory
(
client
)
crudtester
:=
framework
.
NewFederatedTypeCRUDTester
(
t
,
adapter
,
fedFixture
.
ClusterClients
)
obj
:=
adapter
.
NewTestObject
(
uuid
.
New
())
crudtester
.
CheckLifecycle
(
obj
)
})
})
}
}
...
@@ -60,35 +56,38 @@ func TestFederationCRUD(t *testing.T) {
...
@@ -60,35 +56,38 @@ func TestFederationCRUD(t *testing.T) {
}
}
for
testName
,
orphanDependents
:=
range
testCases
{
for
testName
,
orphanDependents
:=
range
testCases
{
t
.
Run
(
testName
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
testName
,
func
(
t
*
testing
.
T
)
{
config
:=
fedFixture
.
APIFixture
.
NewConfig
()
fixture
,
crudTester
,
obj
:=
initCRUDTest
(
t
,
&
fedFixture
,
adapterFactory
,
kind
)
fixture
:=
framework
.
NewControllerFixture
(
t
,
kind
,
adapterFactory
,
config
)
defer
fixture
.
TearDown
(
t
)
defer
fixture
.
TearDown
(
t
)
client
:=
fedFixture
.
APIFixture
.
NewClient
(
fmt
.
Sprintf
(
"deletion-test-%s"
,
kind
))
updatedObj
:=
crudTester
.
CheckCreate
(
obj
)
adapter
:=
adapterFactory
(
client
)
crudTester
.
CheckDelete
(
updatedObj
,
orphanDependents
)
crudtester
:=
framework
.
NewFederatedTypeCRUDTester
(
t
,
adapter
,
fedFixture
.
ClusterClients
)
obj
:=
adapter
.
NewTestObject
(
uuid
.
New
())
updatedObj
:=
crudtester
.
CheckCreate
(
obj
)
crudtester
.
CheckDelete
(
updatedObj
,
orphanDependents
)
})
})
}
}
t
.
Run
(
"Resource should be propagated to a newly added cluster"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Resource should be propagated to a newly added cluster"
,
func
(
t
*
testing
.
T
)
{
config
:=
fedFixture
.
APIFixture
.
NewConfig
()
fixture
,
crudTester
,
obj
:=
initCRUDTest
(
t
,
&
fedFixture
,
adapterFactory
,
kind
)
fixture
:=
framework
.
NewControllerFixture
(
t
,
kind
,
adapterFactory
,
config
)
defer
fixture
.
TearDown
(
t
)
defer
fixture
.
TearDown
(
t
)
client
:=
fedFixture
.
APIFixture
.
NewClient
(
fmt
.
Sprintf
(
"cluster-addition-test-%s"
,
kind
))
updatedObj
:=
crudTester
.
CheckCreate
(
obj
)
adapter
:=
adapterFactory
(
client
)
crudtester
:=
framework
.
NewFederatedTypeCRUDTester
(
t
,
adapter
,
fedFixture
.
ClusterClients
)
obj
:=
adapter
.
NewTestObject
(
uuid
.
New
())
updatedObj
:=
crudtester
.
CheckCreate
(
obj
)
// Start a new cluster and validate that the resource is propagated to it.
// Start a new cluster and validate that the resource is propagated to it.
fedFixture
.
StartCluster
(
t
)
fedFixture
.
StartCluster
(
t
)
// Check propagation to the new cluster by providing the updated set of clients
// Check propagation to the new cluster by providing the updated set of clients
crud
t
ester
.
CheckPropagationForClients
(
updatedObj
,
fedFixture
.
ClusterClients
)
crud
T
ester
.
CheckPropagationForClients
(
updatedObj
,
fedFixture
.
ClusterClients
)
})
})
}
}
// 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
)
{
config
:=
fedFixture
.
APIFixture
.
NewConfig
()
fixture
:=
framework
.
NewControllerFixture
(
t
,
kind
,
adapterFactory
,
config
)
client
:=
fedFixture
.
APIFixture
.
NewClient
(
fmt
.
Sprintf
(
"crud-test-%s"
,
kind
))
adapter
:=
adapterFactory
(
client
)
crudTester
:=
framework
.
NewFederatedTypeCRUDTester
(
t
,
adapter
,
fedFixture
.
ClusterClients
)
obj
:=
adapter
.
NewTestObject
(
uuid
.
New
())
return
fixture
,
crudTester
,
obj
}
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