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
8ca1b309
Commit
8ca1b309
authored
Nov 08, 2016
by
nikhiljindal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing federation secret controller unit test flakiness
parent
03348bb8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
secret_controller_test.go
...kg/federation-controller/secret/secret_controller_test.go
+22
-2
No files found.
federation/pkg/federation-controller/secret/secret_controller_test.go
View file @
8ca1b309
...
@@ -127,6 +127,12 @@ func TestSecretController(t *testing.T) {
...
@@ -127,6 +127,12 @@ func TestSecretController(t *testing.T) {
assert
.
Equal
(
t
,
secret1
.
Namespace
,
updatedSecret
.
Namespace
)
assert
.
Equal
(
t
,
secret1
.
Namespace
,
updatedSecret
.
Namespace
)
assert
.
True
(
t
,
secretsEqual
(
secret1
,
*
updatedSecret
),
assert
.
True
(
t
,
secretsEqual
(
secret1
,
*
updatedSecret
),
fmt
.
Sprintf
(
"expected: %v, actual: %v"
,
secret1
,
*
updatedSecret
))
fmt
.
Sprintf
(
"expected: %v, actual: %v"
,
secret1
,
*
updatedSecret
))
// Wait for the secret to be updated in the informer store.
err
=
WaitForSecretStoreUpdate
(
secretController
.
secretFederatedInformer
.
GetTargetStore
(),
cluster1
.
Name
,
types
.
NamespacedName
{
Namespace
:
secret1
.
Namespace
,
Name
:
secret1
.
Name
}
.
String
(),
updatedSecret
,
wait
.
ForeverTestTimeout
)
assert
.
Nil
(
t
,
err
,
"secret should have been updated in the informer store"
)
// Test update federated secret.
// Test update federated secret.
secret1
.
Data
=
map
[
string
][]
byte
{
secret1
.
Data
=
map
[
string
][]
byte
{
...
@@ -134,8 +140,8 @@ func TestSecretController(t *testing.T) {
...
@@ -134,8 +140,8 @@ func TestSecretController(t *testing.T) {
}
}
secretWatch
.
Modify
(
&
secret1
)
secretWatch
.
Modify
(
&
secret1
)
updatedSecret2
:=
GetSecretFromChan
(
cluster1UpdateChan
)
updatedSecret2
:=
GetSecretFromChan
(
cluster1UpdateChan
)
assert
.
NotNil
(
t
,
updatedSecret
)
assert
.
NotNil
(
t
,
updatedSecret
2
)
assert
.
Equal
(
t
,
secret1
.
Name
,
updatedSecret
.
Name
)
assert
.
Equal
(
t
,
secret1
.
Name
,
updatedSecret
2
.
Name
)
assert
.
Equal
(
t
,
secret1
.
Namespace
,
updatedSecret
.
Namespace
)
assert
.
Equal
(
t
,
secret1
.
Namespace
,
updatedSecret
.
Namespace
)
assert
.
True
(
t
,
secretsEqual
(
secret1
,
*
updatedSecret2
),
assert
.
True
(
t
,
secretsEqual
(
secret1
,
*
updatedSecret2
),
fmt
.
Sprintf
(
"expected: %v, actual: %v"
,
secret1
,
*
updatedSecret2
))
fmt
.
Sprintf
(
"expected: %v, actual: %v"
,
secret1
,
*
updatedSecret2
))
...
@@ -171,3 +177,17 @@ func GetSecretFromChan(c chan runtime.Object) *api_v1.Secret {
...
@@ -171,3 +177,17 @@ func GetSecretFromChan(c chan runtime.Object) *api_v1.Secret {
secret
:=
GetObjectFromChan
(
c
)
.
(
*
api_v1
.
Secret
)
secret
:=
GetObjectFromChan
(
c
)
.
(
*
api_v1
.
Secret
)
return
secret
return
secret
}
}
// Wait till the store is updated with latest secret.
func
WaitForSecretStoreUpdate
(
store
util
.
FederatedReadOnlyStore
,
clusterName
,
key
string
,
desiredSecret
*
api_v1
.
Secret
,
timeout
time
.
Duration
)
error
{
retryInterval
:=
100
*
time
.
Millisecond
err
:=
wait
.
PollImmediate
(
retryInterval
,
timeout
,
func
()
(
bool
,
error
)
{
obj
,
found
,
err
:=
store
.
GetByKey
(
clusterName
,
key
)
if
!
found
||
err
!=
nil
{
return
false
,
err
}
equal
:=
secretsEqual
(
*
obj
.
(
*
api_v1
.
Secret
),
*
desiredSecret
)
return
equal
,
err
})
return
err
}
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