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
578f17c6
Commit
578f17c6
authored
May 12, 2017
by
Maru Newby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fed: Add integration testing for cluster addition
parent
ea61af57
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
8 deletions
+33
-8
crudtester.go
federation/pkg/federatedtypes/crudtester/crudtester.go
+8
-2
crud_test.go
test/integration/federation/crud_test.go
+25
-6
No files found.
federation/pkg/federatedtypes/crudtester/crudtester.go
View file @
578f17c6
...
@@ -163,11 +163,17 @@ func (c *FederatedTypeCRUDTester) CheckDelete(obj pkgruntime.Object, orphanDepen
...
@@ -163,11 +163,17 @@ func (c *FederatedTypeCRUDTester) CheckDelete(obj pkgruntime.Object, orphanDepen
}
}
}
}
// CheckPropagation checks propagation for the crud tester's clients
func
(
c
*
FederatedTypeCRUDTester
)
CheckPropagation
(
obj
pkgruntime
.
Object
)
{
func
(
c
*
FederatedTypeCRUDTester
)
CheckPropagation
(
obj
pkgruntime
.
Object
)
{
c
.
CheckPropagationForClients
(
obj
,
c
.
clusterClients
)
}
// CheckPropagationForClients checks propagation for the provided clients
func
(
c
*
FederatedTypeCRUDTester
)
CheckPropagationForClients
(
obj
pkgruntime
.
Object
,
clusterClients
[]
clientset
.
Interface
)
{
namespacedName
:=
c
.
adapter
.
NamespacedName
(
obj
)
namespacedName
:=
c
.
adapter
.
NamespacedName
(
obj
)
c
.
tl
.
Logf
(
"Waiting for %s %q in %d clusters"
,
c
.
kind
,
namespacedName
,
len
(
c
.
c
lusterClients
))
c
.
tl
.
Logf
(
"Waiting for %s %q in %d clusters"
,
c
.
kind
,
namespacedName
,
len
(
clusterClients
))
for
_
,
client
:=
range
c
.
c
lusterClients
{
for
_
,
client
:=
range
clusterClients
{
err
:=
c
.
waitForResource
(
client
,
obj
)
err
:=
c
.
waitForResource
(
client
,
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
tl
.
Fatalf
(
"Failed to verify %s %q in a member cluster: %v"
,
c
.
kind
,
namespacedName
,
err
)
c
.
tl
.
Fatalf
(
"Failed to verify %s %q in a member cluster: %v"
,
c
.
kind
,
namespacedName
,
err
)
...
...
test/integration/federation/crud_test.go
View file @
578f17c6
...
@@ -48,15 +48,16 @@ func TestFederationCRUD(t *testing.T) {
...
@@ -48,15 +48,16 @@ func TestFederationCRUD(t *testing.T) {
})
})
}
}
// Validate deletion handling where orphanDependents is true or nil for a single resource type since the
// The following tests target a single type since the underlying logic is common across all types.
// underlying logic is common across all types.
kind
:=
federatedtypes
.
SecretKind
adapterFactory
:=
federatedtypes
.
NewSecretAdapter
// Validate deletion handling where orphanDependents is true or nil
orphanedDependents
:=
true
orphanedDependents
:=
true
testCases
:=
map
[
string
]
*
bool
{
testCases
:=
map
[
string
]
*
bool
{
"Resource
s
should not be deleted from underlying clusters when OrphanDependents is true"
:
&
orphanedDependents
,
"Resource should not be deleted from underlying clusters when OrphanDependents is true"
:
&
orphanedDependents
,
"Resource
s
should not be deleted from underlying clusters when OrphanDependents is nil"
:
nil
,
"Resource should not be deleted from underlying clusters when OrphanDependents is nil"
:
nil
,
}
}
kind
:=
federatedtypes
.
SecretKind
adapterFactory
:=
federatedtypes
.
NewSecretAdapter
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
()
config
:=
fedFixture
.
APIFixture
.
NewConfig
()
...
@@ -72,4 +73,22 @@ func TestFederationCRUD(t *testing.T) {
...
@@ -72,4 +73,22 @@ func TestFederationCRUD(t *testing.T) {
crudtester
.
CheckDelete
(
updatedObj
,
orphanDependents
)
crudtester
.
CheckDelete
(
updatedObj
,
orphanDependents
)
})
})
}
}
t
.
Run
(
"Resource should be propagated to a newly added cluster"
,
func
(
t
*
testing
.
T
)
{
config
:=
fedFixture
.
APIFixture
.
NewConfig
()
fixture
:=
framework
.
NewControllerFixture
(
t
,
kind
,
adapterFactory
,
config
)
defer
fixture
.
TearDown
(
t
)
client
:=
fedFixture
.
APIFixture
.
NewClient
(
fmt
.
Sprintf
(
"cluster-addition-test-%s"
,
kind
))
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.
fedFixture
.
StartCluster
(
t
)
// Check propagation to the new cluster by providing the updated set of clients
crudtester
.
CheckPropagationForClients
(
updatedObj
,
fedFixture
.
ClusterClients
)
})
}
}
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