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
bade0169
Commit
bade0169
authored
Oct 31, 2016
by
shashidharatd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Guestbook App to k8s upgrade tests
parent
4bbd4044
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
33 deletions
+99
-33
cluster_upgrade.go
test/e2e/cluster_upgrade.go
+45
-0
kubectl.go
test/e2e/kubectl.go
+54
-33
No files found.
test/e2e/cluster_upgrade.go
View file @
bade0169
...
@@ -50,6 +50,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
...
@@ -50,6 +50,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
testServiceRemainsUp
(
f
,
sem
)
testServiceRemainsUp
(
f
,
sem
)
testSecretsDuringUpgrade
(
f
,
sem
)
testSecretsDuringUpgrade
(
f
,
sem
)
testConfigMapsDuringUpgrade
(
f
,
sem
)
testConfigMapsDuringUpgrade
(
f
,
sem
)
testGuestbookApplicationDuringUpgrade
(
f
,
sem
)
})
})
cm
.
Do
()
cm
.
Do
()
})
})
...
@@ -68,6 +69,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
...
@@ -68,6 +69,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
testServiceUpBeforeAndAfter
(
f
,
sem
)
testServiceUpBeforeAndAfter
(
f
,
sem
)
testSecretsBeforeAndAfterUpgrade
(
f
,
sem
)
testSecretsBeforeAndAfterUpgrade
(
f
,
sem
)
testConfigMapsBeforeAndAfterUpgrade
(
f
,
sem
)
testConfigMapsBeforeAndAfterUpgrade
(
f
,
sem
)
testGuestbookApplicationBeforeAndAfterUpgrade
(
f
,
sem
)
})
})
cm
.
Do
()
cm
.
Do
()
})
})
...
@@ -84,6 +86,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
...
@@ -84,6 +86,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
testServiceRemainsUp
(
f
,
sem
)
testServiceRemainsUp
(
f
,
sem
)
testSecretsDuringUpgrade
(
f
,
sem
)
testSecretsDuringUpgrade
(
f
,
sem
)
testConfigMapsDuringUpgrade
(
f
,
sem
)
testConfigMapsDuringUpgrade
(
f
,
sem
)
testGuestbookApplicationDuringUpgrade
(
f
,
sem
)
})
})
cm
.
Do
()
cm
.
Do
()
})
})
...
@@ -104,6 +107,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
...
@@ -104,6 +107,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
testServiceUpBeforeAndAfter
(
f
,
sem
)
testServiceUpBeforeAndAfter
(
f
,
sem
)
testSecretsBeforeAndAfterUpgrade
(
f
,
sem
)
testSecretsBeforeAndAfterUpgrade
(
f
,
sem
)
testConfigMapsBeforeAndAfterUpgrade
(
f
,
sem
)
testConfigMapsBeforeAndAfterUpgrade
(
f
,
sem
)
testGuestbookApplicationBeforeAndAfterUpgrade
(
f
,
sem
)
})
})
cm
.
Do
()
cm
.
Do
()
})
})
...
@@ -122,6 +126,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
...
@@ -122,6 +126,7 @@ var _ = framework.KubeDescribe("Upgrade [Feature:Upgrade]", func() {
testServiceRemainsUp
(
f
,
sem
)
testServiceRemainsUp
(
f
,
sem
)
testSecretsDuringUpgrade
(
f
,
sem
)
testSecretsDuringUpgrade
(
f
,
sem
)
testConfigMapsDuringUpgrade
(
f
,
sem
)
testConfigMapsDuringUpgrade
(
f
,
sem
)
testGuestbookApplicationDuringUpgrade
(
f
,
sem
)
})
})
cm
.
Do
()
cm
.
Do
()
})
})
...
@@ -312,3 +317,43 @@ func testConfigMaps(f *framework.Framework, sem *chaosmonkey.Semaphore, testDuri
...
@@ -312,3 +317,43 @@ func testConfigMaps(f *framework.Framework, sem *chaosmonkey.Semaphore, testDuri
// Teardown
// Teardown
}
}
func
testGuestbookApplicationBeforeAndAfterUpgrade
(
f
*
framework
.
Framework
,
sem
*
chaosmonkey
.
Semaphore
)
{
testGuestbookApplication
(
f
,
sem
,
false
)
}
func
testGuestbookApplicationDuringUpgrade
(
f
*
framework
.
Framework
,
sem
*
chaosmonkey
.
Semaphore
)
{
testGuestbookApplication
(
f
,
sem
,
true
)
}
func
testGuestbookApplication
(
f
*
framework
.
Framework
,
sem
*
chaosmonkey
.
Semaphore
,
testDuringDisruption
bool
)
{
// Setup
By
(
"setup guestbook app"
)
GuestbookApplicationSetup
(
f
.
ClientSet
,
f
.
Namespace
.
Name
)
// Validate
By
(
"validate guestbook app before upgrade"
)
GuestbookApplicationValidate
(
f
.
ClientSet
,
f
.
Namespace
.
Name
)
sem
.
Ready
()
if
testDuringDisruption
{
// Continuously validate
wait
.
Until
(
func
()
{
By
(
"validate guestbook app during upgrade"
)
GuestbookApplicationValidate
(
f
.
ClientSet
,
f
.
Namespace
.
Name
)
},
framework
.
Poll
,
sem
.
StopCh
)
}
else
{
// Block until chaosmonkey is done
By
(
"waiting for upgrade to finish without validating guestbook app"
)
<-
sem
.
StopCh
}
// Validate after upgrade
By
(
"validate guestbook app after upgrade"
)
GuestbookApplicationValidate
(
f
.
ClientSet
,
f
.
Namespace
.
Name
)
// Teardown
By
(
"teardown guestbook app"
)
GuestbookApplicationTeardown
(
f
.
ClientSet
,
f
.
Namespace
.
Name
)
}
test/e2e/kubectl.go
View file @
bade0169
...
@@ -335,34 +335,8 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
...
@@ -335,34 +335,8 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
})
})
framework
.
KubeDescribe
(
"Guestbook application"
,
func
()
{
framework
.
KubeDescribe
(
"Guestbook application"
,
func
()
{
forEachGBFile
:=
func
(
run
func
(
s
string
))
{
for
_
,
gbAppFile
:=
range
[]
string
{
"examples/guestbook/frontend-deployment.yaml"
,
"examples/guestbook/frontend-service.yaml"
,
"examples/guestbook/redis-master-deployment.yaml"
,
"examples/guestbook/redis-master-service.yaml"
,
"examples/guestbook/redis-slave-deployment.yaml"
,
"examples/guestbook/redis-slave-service.yaml"
,
}
{
contents
:=
framework
.
ReadOrDie
(
gbAppFile
)
run
(
string
(
contents
))
}
}
It
(
"should create and stop a working application [Conformance]"
,
func
()
{
It
(
"should create and stop a working application [Conformance]"
,
func
()
{
framework
.
SkipUnlessServerVersionGTE
(
deploymentsVersion
,
c
.
Discovery
())
guestbookApplication
(
c
,
ns
)
defer
forEachGBFile
(
func
(
contents
string
)
{
cleanupKubectlInputs
(
contents
,
ns
)
})
By
(
"creating all guestbook components"
)
forEachGBFile
(
func
(
contents
string
)
{
framework
.
Logf
(
contents
)
framework
.
RunKubectlOrDieInput
(
contents
,
"create"
,
"-f"
,
"-"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
))
})
By
(
"validating guestbook app"
)
validateGuestbookApp
(
c
,
ns
)
})
})
})
})
...
@@ -1597,27 +1571,32 @@ func validateGuestbookApp(c clientset.Interface, ns string) {
...
@@ -1597,27 +1571,32 @@ func validateGuestbookApp(c clientset.Interface, ns string) {
err
:=
testutils
.
WaitForPodsWithLabelRunning
(
c
,
ns
,
label
)
err
:=
testutils
.
WaitForPodsWithLabelRunning
(
c
,
ns
,
label
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
framework
.
Logf
(
"Waiting for frontend to serve content."
)
framework
.
Logf
(
"Waiting for frontend to serve content."
)
if
!
waitForGuestbookResponse
(
c
,
"get"
,
""
,
`{"data": ""}`
,
guestbookStartupTimeout
,
ns
)
{
// the response could be {"data": ""} or "data": "TestEntry"} depending on how many times validateGuestbookApp is called
if
!
waitForGuestbookResponse
(
c
,
"get"
,
""
,
[]
string
{
`{"data": ""}`
,
`{"data": "TestEntry"}`
},
guestbookStartupTimeout
,
ns
)
{
framework
.
Failf
(
"Frontend service did not start serving content in %v seconds."
,
guestbookStartupTimeout
.
Seconds
())
framework
.
Failf
(
"Frontend service did not start serving content in %v seconds."
,
guestbookStartupTimeout
.
Seconds
())
}
}
framework
.
Logf
(
"Trying to add a new entry to the guestbook."
)
framework
.
Logf
(
"Trying to add a new entry to the guestbook."
)
if
!
waitForGuestbookResponse
(
c
,
"set"
,
"TestEntry"
,
`{"message": "Updated"}`
,
guestbookResponseTimeout
,
ns
)
{
if
!
waitForGuestbookResponse
(
c
,
"set"
,
"TestEntry"
,
[]
string
{
`{"message": "Updated"}`
}
,
guestbookResponseTimeout
,
ns
)
{
framework
.
Failf
(
"Cannot added new entry in %v seconds."
,
guestbookResponseTimeout
.
Seconds
())
framework
.
Failf
(
"Cannot added new entry in %v seconds."
,
guestbookResponseTimeout
.
Seconds
())
}
}
framework
.
Logf
(
"Verifying that added entry can be retrieved."
)
framework
.
Logf
(
"Verifying that added entry can be retrieved."
)
if
!
waitForGuestbookResponse
(
c
,
"get"
,
""
,
`{"data": "TestEntry"}`
,
guestbookResponseTimeout
,
ns
)
{
if
!
waitForGuestbookResponse
(
c
,
"get"
,
""
,
[]
string
{
`{"data": "TestEntry"}`
}
,
guestbookResponseTimeout
,
ns
)
{
framework
.
Failf
(
"Entry to guestbook wasn't correctly added in %v seconds."
,
guestbookResponseTimeout
.
Seconds
())
framework
.
Failf
(
"Entry to guestbook wasn't correctly added in %v seconds."
,
guestbookResponseTimeout
.
Seconds
())
}
}
}
}
// Returns whether received expected response from guestbook on time.
// Returns whether received expected response from guestbook on time.
func
waitForGuestbookResponse
(
c
clientset
.
Interface
,
cmd
,
arg
,
expectedResponse
string
,
timeout
time
.
Duration
,
ns
string
)
bool
{
func
waitForGuestbookResponse
(
c
clientset
.
Interface
,
cmd
,
arg
string
,
expectedResponse
[]
string
,
timeout
time
.
Duration
,
ns
string
)
bool
{
for
start
:=
time
.
Now
();
time
.
Since
(
start
)
<
timeout
;
time
.
Sleep
(
5
*
time
.
Second
)
{
for
start
:=
time
.
Now
();
time
.
Since
(
start
)
<
timeout
;
time
.
Sleep
(
5
*
time
.
Second
)
{
res
,
err
:=
makeRequestToGuestbook
(
c
,
cmd
,
arg
,
ns
)
res
,
err
:=
makeRequestToGuestbook
(
c
,
cmd
,
arg
,
ns
)
if
err
==
nil
&&
res
==
expectedResponse
{
if
err
==
nil
{
return
true
for
_
,
expResp
:=
range
expectedResponse
{
if
res
==
expResp
{
return
true
}
}
}
}
framework
.
Logf
(
"Failed to get response from guestbook. err: %v, response: %s"
,
err
,
res
)
framework
.
Logf
(
"Failed to get response from guestbook. err: %v, response: %s"
,
err
,
res
)
}
}
...
@@ -1832,3 +1811,45 @@ func startLocalProxy() (srv *httptest.Server, logs *bytes.Buffer) {
...
@@ -1832,3 +1811,45 @@ func startLocalProxy() (srv *httptest.Server, logs *bytes.Buffer) {
p
.
Logger
=
log
.
New
(
logs
,
""
,
0
)
p
.
Logger
=
log
.
New
(
logs
,
""
,
0
)
return
httptest
.
NewServer
(
p
),
logs
return
httptest
.
NewServer
(
p
),
logs
}
}
func
forEachGuestbookFile
(
run
func
(
s
string
))
{
for
_
,
gbAppFile
:=
range
[]
string
{
"examples/guestbook/frontend-deployment.yaml"
,
"examples/guestbook/frontend-service.yaml"
,
"examples/guestbook/redis-master-deployment.yaml"
,
"examples/guestbook/redis-master-service.yaml"
,
"examples/guestbook/redis-slave-deployment.yaml"
,
"examples/guestbook/redis-slave-service.yaml"
,
}
{
contents
:=
framework
.
ReadOrDie
(
gbAppFile
)
run
(
string
(
contents
))
}
}
func
GuestbookApplicationSetup
(
c
clientset
.
Interface
,
ns
string
)
{
framework
.
SkipUnlessServerVersionGTE
(
deploymentsVersion
,
c
.
Discovery
())
By
(
"creating all guestbook components"
)
forEachGuestbookFile
(
func
(
contents
string
)
{
framework
.
Logf
(
contents
)
framework
.
RunKubectlOrDieInput
(
contents
,
"create"
,
"-f"
,
"-"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
))
})
}
func
GuestbookApplicationValidate
(
c
clientset
.
Interface
,
ns
string
)
{
By
(
"validating guestbook app"
)
validateGuestbookApp
(
c
,
ns
)
}
func
GuestbookApplicationTeardown
(
c
clientset
.
Interface
,
ns
string
)
{
By
(
"teardown guestbook app"
)
forEachGuestbookFile
(
func
(
contents
string
)
{
cleanupKubectlInputs
(
contents
,
ns
)
})
}
func
guestbookApplication
(
c
clientset
.
Interface
,
ns
string
)
{
GuestbookApplicationSetup
(
c
,
ns
)
GuestbookApplicationValidate
(
c
,
ns
)
GuestbookApplicationTeardown
(
c
,
ns
)
}
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