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
6dfec4a2
Unverified
Commit
6dfec4a2
authored
May 29, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #78386 from SataQiu/fix-test-golint-20190527
Fix golint failures of test/e2e/chaosmonkey
parents
ade661c7
a6e0614d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
21 deletions
+21
-21
.golint_failures
hack/.golint_failures
+0
-1
chaosmonkey.go
test/e2e/chaosmonkey/chaosmonkey.go
+20
-19
chaosmonkey_test.go
test/e2e/chaosmonkey/chaosmonkey_test.go
+1
-1
No files found.
hack/.golint_failures
View file @
6dfec4a2
...
@@ -584,7 +584,6 @@ staging/src/k8s.io/sample-apiserver/pkg/apis/wardle
...
@@ -584,7 +584,6 @@ staging/src/k8s.io/sample-apiserver/pkg/apis/wardle
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder
test/e2e/chaosmonkey
test/e2e/common
test/e2e/common
test/e2e/lifecycle/bootstrap
test/e2e/lifecycle/bootstrap
test/e2e/scalability
test/e2e/scalability
...
...
test/e2e/chaosmonkey/chaosmonkey.go
View file @
6dfec4a2
...
@@ -16,13 +16,13 @@ limitations under the License.
...
@@ -16,13 +16,13 @@ limitations under the License.
package
chaosmonkey
package
chaosmonkey
import
.
"github.com/onsi/ginkgo"
import
"github.com/onsi/ginkgo"
// Disruption is the type to construct a
c
haosmonkey with; see Do for more information.
// Disruption is the type to construct a
C
haosmonkey with; see Do for more information.
type
Disruption
func
()
type
Disruption
func
()
// Test is the type to register with a
c
haosmonkey. A test will run asynchronously across the
// Test is the type to register with a
C
haosmonkey. A test will run asynchronously across the
//
c
haosmonkey's Disruption. A Test takes a Semaphore as an argument. It should call sem.Ready()
//
C
haosmonkey's Disruption. A Test takes a Semaphore as an argument. It should call sem.Ready()
// once it's ready for the disruption to start and should then wait until sem.StopCh (which is a
// once it's ready for the disruption to start and should then wait until sem.StopCh (which is a
// <-chan struct{}) is closed, which signals that the disruption is over. It should then clean up
// <-chan struct{}) is closed, which signals that the disruption is over. It should then clean up
// and return. See Do and Semaphore for more information.
// and return. See Do and Semaphore for more information.
...
@@ -37,30 +37,31 @@ type Interface interface {
...
@@ -37,30 +37,31 @@ type Interface interface {
Teardown
()
Teardown
()
}
}
type
chaosmonkey
struct
{
// Chaosmonkey is the type that holds the necessary content for chaosmonkey test
type
Chaosmonkey
struct
{
disruption
Disruption
disruption
Disruption
tests
[]
Test
tests
[]
Test
}
}
// New creates and returns a
c
haosmonkey, with which the caller should register Tests and call Do.
// New creates and returns a
C
haosmonkey, with which the caller should register Tests and call Do.
// See Do for more information.
// See Do for more information.
func
New
(
disruption
Disruption
)
*
c
haosmonkey
{
func
New
(
disruption
Disruption
)
*
C
haosmonkey
{
return
&
c
haosmonkey
{
return
&
C
haosmonkey
{
disruption
,
disruption
,
[]
Test
{},
[]
Test
{},
}
}
}
}
// Register registers the given Test with the
c
haosmonkey, so that the test will run over the
// Register registers the given Test with the
C
haosmonkey, so that the test will run over the
// Disruption.
// Disruption.
func
(
cm
*
c
haosmonkey
)
Register
(
test
Test
)
{
func
(
cm
*
C
haosmonkey
)
Register
(
test
Test
)
{
cm
.
tests
=
append
(
cm
.
tests
,
test
)
cm
.
tests
=
append
(
cm
.
tests
,
test
)
}
}
// RegisterInterface registers the given Interface with the
chaosmonkey, so the c
haosmonkey will
// RegisterInterface registers the given Interface with the
Chaosmonkey, so the C
haosmonkey will
// call Setup, Test, and Teardown properly. Test can tell that the Disruption is finished when
// call Setup, Test, and Teardown properly. Test can tell that the Disruption is finished when
// stopCh is closed.
// stopCh is closed.
func
(
cm
*
c
haosmonkey
)
RegisterInterface
(
in
Interface
)
{
func
(
cm
*
C
haosmonkey
)
RegisterInterface
(
in
Interface
)
{
cm
.
Register
(
func
(
sem
*
Semaphore
)
{
cm
.
Register
(
func
(
sem
*
Semaphore
)
{
in
.
Setup
()
in
.
Setup
()
sem
.
Ready
()
sem
.
Ready
()
...
@@ -70,11 +71,11 @@ func (cm *chaosmonkey) RegisterInterface(in Interface) {
...
@@ -70,11 +71,11 @@ func (cm *chaosmonkey) RegisterInterface(in Interface) {
}
}
// Do performs the Disruption while testing the registered Tests. Once the caller has registered
// Do performs the Disruption while testing the registered Tests. Once the caller has registered
// all Tests with the
c
haosmonkey, they call Do. Do starts each registered test asynchronously and
// all Tests with the
C
haosmonkey, they call Do. Do starts each registered test asynchronously and
// waits for each test to signal that it is ready by calling sem.Ready(). Do will then do the
// waits for each test to signal that it is ready by calling sem.Ready(). Do will then do the
// Disruption, and when it's complete, close sem.StopCh to signal to the registered Tests that the
// Disruption, and when it's complete, close sem.StopCh to signal to the registered Tests that the
// Disruption is over, and wait for all Tests to return.
// Disruption is over, and wait for all Tests to return.
func
(
cm
*
c
haosmonkey
)
Do
()
{
func
(
cm
*
C
haosmonkey
)
Do
()
{
sems
:=
[]
*
Semaphore
{}
sems
:=
[]
*
Semaphore
{}
// All semaphores have the same StopCh.
// All semaphores have the same StopCh.
stopCh
:=
make
(
chan
struct
{})
stopCh
:=
make
(
chan
struct
{})
...
@@ -84,13 +85,13 @@ func (cm *chaosmonkey) Do() {
...
@@ -84,13 +85,13 @@ func (cm *chaosmonkey) Do() {
sem
:=
newSemaphore
(
stopCh
)
sem
:=
newSemaphore
(
stopCh
)
sems
=
append
(
sems
,
sem
)
sems
=
append
(
sems
,
sem
)
go
func
()
{
go
func
()
{
defer
GinkgoRecover
()
defer
ginkgo
.
GinkgoRecover
()
defer
sem
.
done
()
defer
sem
.
done
()
test
(
sem
)
test
(
sem
)
}()
}()
}
}
By
(
"Waiting for all async tests to be ready"
)
ginkgo
.
By
(
"Waiting for all async tests to be ready"
)
for
_
,
sem
:=
range
sems
{
for
_
,
sem
:=
range
sems
{
// Wait for test to be ready. We have to wait for ready *or done* because a test
// Wait for test to be ready. We have to wait for ready *or done* because a test
// may panic before signaling that its ready, and we shouldn't block. Since we
// may panic before signaling that its ready, and we shouldn't block. Since we
...
@@ -100,15 +101,15 @@ func (cm *chaosmonkey) Do() {
...
@@ -100,15 +101,15 @@ func (cm *chaosmonkey) Do() {
defer
func
()
{
defer
func
()
{
close
(
stopCh
)
close
(
stopCh
)
By
(
"Waiting for async validations to complete"
)
ginkgo
.
By
(
"Waiting for async validations to complete"
)
for
_
,
sem
:=
range
sems
{
for
_
,
sem
:=
range
sems
{
sem
.
waitForDone
()
sem
.
waitForDone
()
}
}
}()
}()
By
(
"Starting disruption"
)
ginkgo
.
By
(
"Starting disruption"
)
cm
.
disruption
()
cm
.
disruption
()
By
(
"Disruption complete; stopping async validations"
)
ginkgo
.
By
(
"Disruption complete; stopping async validations"
)
}
}
// Semaphore is taken by a Test and provides: Ready(), for the Test to call when it's ready for the
// Semaphore is taken by a Test and provides: Ready(), for the Test to call when it's ready for the
...
...
test/e2e/chaosmonkey/chaosmonkey_test.go
View file @
6dfec4a2
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
)
)
func
TestDoWithPanic
(
t
*
testing
.
T
)
{
func
TestDoWithPanic
(
t
*
testing
.
T
)
{
var
counter
int64
=
0
var
counter
int64
cm
:=
New
(
func
()
{})
cm
:=
New
(
func
()
{})
tests
:=
[]
Test
{
tests
:=
[]
Test
{
// No panic
// No panic
...
...
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