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
ce811116
Commit
ce811116
authored
Mar 09, 2017
by
Madhusudan.C.S
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Federation] Add a new helper function to create replicasets with name for updates in e2es.
parent
442e9200
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
15 deletions
+42
-15
replicaset.go
test/e2e_federation/replicaset.go
+42
-15
No files found.
test/e2e_federation/replicaset.go
View file @
ce811116
...
@@ -41,7 +41,7 @@ import (
...
@@ -41,7 +41,7 @@ import (
const
(
const
(
FederationReplicaSetPrefix
=
"federation-replicaset-"
FederationReplicaSetPrefix
=
"federation-replicaset-"
FederatedReplicaSetTimeout
=
120
*
time
.
Second
FederatedReplicaSetTimeout
=
2
*
time
.
Minute
)
)
// Create/delete replicaset api objects
// Create/delete replicaset api objects
...
@@ -93,6 +93,9 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
...
@@ -93,6 +93,9 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
// cleanup. deletion of replicasets is not supported for underling clusters
// cleanup. deletion of replicasets is not supported for underling clusters
By
(
fmt
.
Sprintf
(
"zero replicas then delete replicaset %q/%q"
,
nsName
,
rs
.
Name
))
By
(
fmt
.
Sprintf
(
"zero replicas then delete replicaset %q/%q"
,
nsName
,
rs
.
Name
))
zeroReplicas
:=
int32
(
0
)
zeroReplicas
:=
int32
(
0
)
rs
.
GenerateName
=
""
rs
.
ResourceVersion
=
""
rs
.
Generation
=
0
rs
.
Spec
.
Replicas
=
&
zeroReplicas
rs
.
Spec
.
Replicas
=
&
zeroReplicas
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
nil
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
nil
)
...
@@ -108,7 +111,7 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
...
@@ -108,7 +111,7 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
nil
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
nil
)
By
(
fmt
.
Sprintf
(
"Successfuly created and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
By
(
fmt
.
Sprintf
(
"Successfuly created and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
rs
=
newReplicaSet
(
nsName
,
FederationReplicaSetPrefix
,
15
,
nil
)
rs
=
newReplicaSet
WithName
(
nsName
,
rs
.
Name
,
15
,
nil
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
nil
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
nil
)
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
...
@@ -117,18 +120,18 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
...
@@ -117,18 +120,18 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
// test for replicaset prefs with weight, min and max replicas
// test for replicaset prefs with weight, min and max replicas
createAndUpdateFn
:=
func
(
pref
*
federation
.
FederatedReplicaSetPreferences
,
replicas
int32
,
expect
map
[
string
]
int32
)
{
createAndUpdateFn
:=
func
(
pref
*
federation
.
FederatedReplicaSetPreferences
,
replicas
int32
,
expect
map
[
string
]
int32
)
{
rs
:=
newReplicaSet
(
nsName
,
FederationReplicaSetPrefix
,
replicas
,
pref
)
rs
:=
newReplicaSet
(
nsName
,
FederationReplicaSetPrefix
,
replicas
,
pref
)
createReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
rs
=
createReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
defer
cleanupFn
(
rs
)
defer
cleanupFn
(
rs
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect
)
By
(
fmt
.
Sprintf
(
"Successfuly created and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
By
(
fmt
.
Sprintf
(
"Successfuly created and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
rs
=
newReplicaSet
(
nsName
,
FederationReplicaSetPrefix
,
0
,
pref
)
rs
=
newReplicaSet
WithName
(
nsName
,
rs
.
Name
,
0
,
pref
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
nil
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
nil
)
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
rs
=
newReplicaSet
(
nsName
,
FederationReplicaSetPrefix
,
replicas
,
pref
)
rs
=
newReplicaSet
WithName
(
nsName
,
rs
.
Name
,
replicas
,
pref
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect
)
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
...
@@ -146,13 +149,13 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
...
@@ -146,13 +149,13 @@ var _ = framework.KubeDescribe("Federation replicasets [Feature:Federation]", fu
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect1
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect1
)
By
(
fmt
.
Sprintf
(
"Successfuly created and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
By
(
fmt
.
Sprintf
(
"Successfuly created and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
rs
=
newReplicaSet
(
nsName
,
FederationReplicaSetPrefix
,
replicas
,
pref2
)
rs
=
newReplicaSet
WithName
(
nsName
,
rs
.
Name
,
replicas
,
pref2
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect1
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect1
)
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
pref2
=
updateFedRePrefsRebalance
(
pref2
,
true
)
pref2
=
updateFedRePrefsRebalance
(
pref2
,
true
)
rs
=
newReplicaSet
(
nsName
,
FederationReplicaSetPrefix
,
replicas
,
pref2
)
rs
=
newReplicaSet
WithName
(
nsName
,
rs
.
Name
,
replicas
,
pref2
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
updateReplicaSetOrFail
(
f
.
FederationClientset
,
rs
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect2
)
waitForReplicaSetOrFail
(
f
.
FederationClientset
,
nsName
,
rs
.
Name
,
clusters
,
expect2
)
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
By
(
fmt
.
Sprintf
(
"Successfuly updated and synced replicaset %q/%q (%v/%v) to clusters"
,
nsName
,
rs
.
Name
,
*
rs
.
Spec
.
Replicas
,
rs
.
Status
.
Replicas
))
...
@@ -423,19 +426,30 @@ func updateReplicaSetOrFail(clientset *fedclientset.Clientset, replicaset *v1bet
...
@@ -423,19 +426,30 @@ func updateReplicaSetOrFail(clientset *fedclientset.Clientset, replicaset *v1bet
}
}
By
(
fmt
.
Sprintf
(
"Updating federation replicaset %q in namespace %q"
,
replicaset
.
Name
,
namespace
))
By
(
fmt
.
Sprintf
(
"Updating federation replicaset %q in namespace %q"
,
replicaset
.
Name
,
namespace
))
newRs
,
err
:=
clientset
.
ReplicaSets
(
namespace
)
.
Update
(
replicaset
)
var
newRS
*
v1beta1
.
ReplicaSet
err
:=
wait
.
Poll
(
5
*
time
.
Second
,
FederatedReplicaSetTimeout
,
func
()
(
bool
,
error
)
{
var
err
error
newRS
,
err
=
clientset
.
ReplicaSets
(
namespace
)
.
Update
(
replicaset
)
if
!
errors
.
IsConflict
(
err
)
{
if
err
!=
nil
{
return
false
,
err
}
return
true
,
nil
}
framework
.
Logf
(
"Retrying due to an update failure: %v"
,
err
)
return
false
,
nil
})
framework
.
ExpectNoError
(
err
,
"Updating replicaset %q in namespace %q"
,
replicaset
.
Name
,
namespace
)
framework
.
ExpectNoError
(
err
,
"Updating replicaset %q in namespace %q"
,
replicaset
.
Name
,
namespace
)
By
(
fmt
.
Sprintf
(
"Successfully updated federation replicaset %q in namespace %q"
,
replicaset
.
Name
,
namespace
))
By
(
fmt
.
Sprintf
(
"Successfully updated federation replicaset %q in namespace %q"
,
replicaset
.
Name
,
namespace
))
return
newR
s
return
newR
S
}
}
func
newReplicaSet
(
namespace
string
,
prefix
string
,
replicas
int32
,
pref
*
federation
.
FederatedReplicaSetPreferences
)
*
v1beta1
.
ReplicaSet
{
func
newReplicaSet
Obj
(
namespace
string
,
replicas
int32
,
pref
*
federation
.
FederatedReplicaSetPreferences
)
*
v1beta1
.
ReplicaSet
{
rs
:=
v1beta1
.
ReplicaSet
{
rs
:=
&
v1beta1
.
ReplicaSet
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
GenerateName
:
prefix
,
Namespace
:
namespace
,
Namespace
:
namespace
,
Annotations
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{},
},
},
Spec
:
v1beta1
.
ReplicaSetSpec
{
Spec
:
v1beta1
.
ReplicaSetSpec
{
Replicas
:
&
replicas
,
Replicas
:
&
replicas
,
...
@@ -462,7 +476,20 @@ func newReplicaSet(namespace string, prefix string, replicas int32, pref *federa
...
@@ -462,7 +476,20 @@ func newReplicaSet(namespace string, prefix string, replicas int32, pref *federa
prefString
:=
string
(
prefBytes
)
prefString
:=
string
(
prefBytes
)
rs
.
Annotations
[
fedreplicsetcontroller
.
FedReplicaSetPreferencesAnnotation
]
=
prefString
rs
.
Annotations
[
fedreplicsetcontroller
.
FedReplicaSetPreferencesAnnotation
]
=
prefString
}
}
return
&
rs
return
rs
}
func
newReplicaSet
(
namespace
string
,
prefix
string
,
replicas
int32
,
pref
*
federation
.
FederatedReplicaSetPreferences
)
*
v1beta1
.
ReplicaSet
{
rs
:=
newReplicaSetObj
(
namespace
,
replicas
,
pref
)
rs
.
GenerateName
=
prefix
return
rs
}
func
newReplicaSetWithName
(
namespace
string
,
name
string
,
replicas
int32
,
pref
*
federation
.
FederatedReplicaSetPreferences
)
*
v1beta1
.
ReplicaSet
{
rs
:=
newReplicaSetObj
(
namespace
,
replicas
,
pref
)
rs
.
Name
=
name
return
rs
}
}
func
extraceClusterNames
(
clusters
map
[
string
]
*
cluster
)
[]
string
{
func
extraceClusterNames
(
clusters
map
[
string
]
*
cluster
)
[]
string
{
...
...
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