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
be8c7536
Commit
be8c7536
authored
Jul 05, 2016
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add standard UpdatePod function in framework, and change
the test to use it.
parent
203e1e96
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
62 deletions
+39
-62
downwardapi_volume.go
test/e2e/downwardapi_volume.go
+5
-12
pods.go
test/e2e/framework/pods.go
+27
-0
pods.go
test/e2e/pods.go
+7
-50
No files found.
test/e2e/downwardapi_volume.go
View file @
be8c7536
...
@@ -75,25 +75,20 @@ var _ = framework.KubeDescribe("Downward API volume", func() {
...
@@ -75,25 +75,20 @@ var _ = framework.KubeDescribe("Downward API volume", func() {
framework
.
ExpectNoError
(
framework
.
WaitForPodRunningInNamespace
(
f
.
Client
,
pod
.
Name
,
f
.
Namespace
.
Name
))
framework
.
ExpectNoError
(
framework
.
WaitForPodRunningInNamespace
(
f
.
Client
,
pod
.
Name
,
f
.
Namespace
.
Name
))
pod
,
err
=
f
.
Client
.
Pods
(
f
.
Namespace
.
Name
)
.
Get
(
pod
.
Name
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Eventually
(
func
()
(
string
,
error
)
{
Eventually
(
func
()
(
string
,
error
)
{
return
framework
.
GetPodLogs
(
f
.
Client
,
f
.
Namespace
.
Name
,
pod
.
Name
,
containerName
)
return
framework
.
GetPodLogs
(
f
.
Client
,
f
.
Namespace
.
Name
,
podName
,
containerName
)
},
},
podLogTimeout
,
framework
.
Poll
)
.
Should
(
ContainSubstring
(
"key1=
\"
value1
\"\n
"
))
podLogTimeout
,
framework
.
Poll
)
.
Should
(
ContainSubstring
(
"key1=
\"
value1
\"\n
"
))
//modify labels
//modify labels
f
.
UpdatePod
(
podName
,
func
(
pod
*
api
.
Pod
)
{
pod
.
Labels
[
"key3"
]
=
"value3"
pod
.
Labels
[
"key3"
]
=
"value3"
pod
.
ResourceVersion
=
""
// to force update
})
_
,
err
=
f
.
Client
.
Pods
(
f
.
Namespace
.
Name
)
.
Update
(
pod
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Eventually
(
func
()
(
string
,
error
)
{
Eventually
(
func
()
(
string
,
error
)
{
return
framework
.
GetPodLogs
(
f
.
Client
,
f
.
Namespace
.
Name
,
pod
.
Name
,
containerName
)
return
framework
.
GetPodLogs
(
f
.
Client
,
f
.
Namespace
.
Name
,
pod
.
Name
,
containerName
)
},
},
podLogTimeout
,
framework
.
Poll
)
.
Should
(
ContainSubstring
(
"key3=
\"
value3
\"\n
"
))
podLogTimeout
,
framework
.
Poll
)
.
Should
(
ContainSubstring
(
"key3=
\"
value3
\"\n
"
))
})
})
It
(
"should update annotations on modification [Conformance]"
,
func
()
{
It
(
"should update annotations on modification [Conformance]"
,
func
()
{
...
@@ -121,16 +116,14 @@ var _ = framework.KubeDescribe("Downward API volume", func() {
...
@@ -121,16 +116,14 @@ var _ = framework.KubeDescribe("Downward API volume", func() {
podLogTimeout
,
framework
.
Poll
)
.
Should
(
ContainSubstring
(
"builder=
\"
bar
\"\n
"
))
podLogTimeout
,
framework
.
Poll
)
.
Should
(
ContainSubstring
(
"builder=
\"
bar
\"\n
"
))
//modify annotations
//modify annotations
f
.
UpdatePod
(
podName
,
func
(
pod
*
api
.
Pod
)
{
pod
.
Annotations
[
"builder"
]
=
"foo"
pod
.
Annotations
[
"builder"
]
=
"foo"
pod
.
ResourceVersion
=
""
// to force update
})
_
,
err
=
f
.
Client
.
Pods
(
f
.
Namespace
.
Name
)
.
Update
(
pod
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Eventually
(
func
()
(
string
,
error
)
{
Eventually
(
func
()
(
string
,
error
)
{
return
framework
.
GetPodLogs
(
f
.
Client
,
f
.
Namespace
.
Name
,
pod
.
Name
,
containerName
)
return
framework
.
GetPodLogs
(
f
.
Client
,
f
.
Namespace
.
Name
,
pod
.
Name
,
containerName
)
},
},
podLogTimeout
,
framework
.
Poll
)
.
Should
(
ContainSubstring
(
"builder=
\"
foo
\"\n
"
))
podLogTimeout
,
framework
.
Poll
)
.
Should
(
ContainSubstring
(
"builder=
\"
foo
\"\n
"
))
})
})
It
(
"should provide container's cpu limit"
,
func
()
{
It
(
"should provide container's cpu limit"
,
func
()
{
...
...
test/e2e/framework/pods.go
View file @
be8c7536
...
@@ -17,10 +17,14 @@ limitations under the License.
...
@@ -17,10 +17,14 @@ limitations under the License.
package
framework
package
framework
import
(
import
(
"fmt"
"sync"
"sync"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/util/wait"
.
"github.com/onsi/gomega"
.
"github.com/onsi/gomega"
)
)
...
@@ -70,3 +74,26 @@ func (f *Framework) MungePodSpec(pod *api.Pod) {
...
@@ -70,3 +74,26 @@ func (f *Framework) MungePodSpec(pod *api.Pod) {
pod
.
Spec
.
NodeName
=
TestContext
.
NodeName
pod
.
Spec
.
NodeName
=
TestContext
.
NodeName
}
}
}
}
// UpdatePod updates the pod object. It retries if there is a conflict, throw out error if
// there is any other errors. name is the pod name, updateFn is the function updating the
// pod object.
func
(
f
*
Framework
)
UpdatePod
(
name
string
,
updateFn
func
(
pod
*
api
.
Pod
))
{
ExpectNoError
(
wait
.
Poll
(
time
.
Millisecond
*
500
,
time
.
Second
*
30
,
func
()
(
bool
,
error
)
{
pod
,
err
:=
f
.
PodClient
()
.
Get
(
name
)
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"failed to get pod %q: %v"
,
name
,
err
)
}
updateFn
(
pod
)
_
,
err
=
f
.
PodClient
()
.
Update
(
pod
)
if
err
==
nil
{
Logf
(
"Successfully updated pod %q"
,
name
)
return
true
,
nil
}
if
errors
.
IsConflict
(
err
)
{
Logf
(
"Conflicting update to pod %q, re-get and re-update: %v"
,
name
,
err
)
return
false
,
nil
}
return
false
,
fmt
.
Errorf
(
"failed to update pod %q: %v"
,
name
,
err
)
}))
}
test/e2e/pods.go
View file @
be8c7536
...
@@ -27,7 +27,6 @@ import (
...
@@ -27,7 +27,6 @@ import (
"golang.org/x/net/websocket"
"golang.org/x/net/websocket"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/kubelet"
"k8s.io/kubernetes/pkg/kubelet"
...
@@ -462,29 +461,11 @@ var _ = framework.KubeDescribe("Pods", func() {
...
@@ -462,29 +461,11 @@ var _ = framework.KubeDescribe("Pods", func() {
pods
,
err
:=
podClient
.
List
(
options
)
pods
,
err
:=
podClient
.
List
(
options
)
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
// Standard get, update retry loop
framework
.
ExpectNoError
(
wait
.
Poll
(
time
.
Millisecond
*
500
,
time
.
Second
*
30
,
func
()
(
bool
,
error
)
{
By
(
"updating the pod"
)
By
(
"updating the pod"
)
f
.
UpdatePod
(
name
,
func
(
pod
*
api
.
Pod
)
{
value
=
strconv
.
Itoa
(
time
.
Now
()
.
Nanosecond
())
value
=
strconv
.
Itoa
(
time
.
Now
()
.
Nanosecond
())
if
pod
==
nil
{
// on retries we need to re-get
pod
,
err
=
podClient
.
Get
(
name
)
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"failed to get pod: %v"
,
err
)
}
}
pod
.
Labels
[
"time"
]
=
value
pod
.
Labels
[
"time"
]
=
value
pod
,
err
=
podClient
.
Update
(
pod
)
})
if
err
==
nil
{
framework
.
Logf
(
"Successfully updated pod"
)
return
true
,
nil
}
if
errors
.
IsConflict
(
err
)
{
framework
.
Logf
(
"Conflicting update to pod, re-get and re-update: %v"
,
err
)
pod
=
nil
// re-get it when we retry
return
false
,
nil
}
return
false
,
fmt
.
Errorf
(
"failed to update pod: %v"
,
err
)
}))
framework
.
ExpectNoError
(
f
.
WaitForPodRunning
(
pod
.
Name
))
framework
.
ExpectNoError
(
f
.
WaitForPodRunning
(
pod
.
Name
))
...
@@ -548,30 +529,11 @@ var _ = framework.KubeDescribe("Pods", func() {
...
@@ -548,30 +529,11 @@ var _ = framework.KubeDescribe("Pods", func() {
pods
,
err
:=
podClient
.
List
(
options
)
pods
,
err
:=
podClient
.
List
(
options
)
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
Expect
(
len
(
pods
.
Items
))
.
To
(
Equal
(
1
))
// Standard get, update retry loop
framework
.
ExpectNoError
(
wait
.
Poll
(
time
.
Millisecond
*
500
,
time
.
Second
*
30
,
func
()
(
bool
,
error
)
{
By
(
"updating the pod"
)
By
(
"updating the pod"
)
value
=
strconv
.
Itoa
(
time
.
Now
()
.
Nanosecond
())
f
.
UpdatePod
(
name
,
func
(
pod
*
api
.
Pod
)
{
if
pod
==
nil
{
// on retries we need to re-get
pod
,
err
=
podClient
.
Get
(
name
)
if
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"failed to get pod: %v"
,
err
)
}
}
newDeadline
:=
int64
(
5
)
newDeadline
:=
int64
(
5
)
pod
.
Spec
.
ActiveDeadlineSeconds
=
&
newDeadline
pod
.
Spec
.
ActiveDeadlineSeconds
=
&
newDeadline
pod
,
err
=
podClient
.
Update
(
pod
)
})
if
err
==
nil
{
framework
.
Logf
(
"Successfully updated pod"
)
return
true
,
nil
}
if
errors
.
IsConflict
(
err
)
{
framework
.
Logf
(
"Conflicting update to pod, re-get and re-update: %v"
,
err
)
pod
=
nil
// re-get it when we retry
return
false
,
nil
}
return
false
,
fmt
.
Errorf
(
"failed to update pod: %v"
,
err
)
}))
framework
.
ExpectNoError
(
f
.
WaitForPodTerminated
(
pod
.
Name
,
"DeadlineExceeded"
))
framework
.
ExpectNoError
(
f
.
WaitForPodTerminated
(
pod
.
Name
,
"DeadlineExceeded"
))
})
})
...
@@ -1347,15 +1309,10 @@ var _ = framework.KubeDescribe("Pods", func() {
...
@@ -1347,15 +1309,10 @@ var _ = framework.KubeDescribe("Pods", func() {
delay1
,
delay2
:=
startPodAndGetBackOffs
(
f
,
pod
,
podName
,
containerName
,
buildBackOffDuration
)
delay1
,
delay2
:=
startPodAndGetBackOffs
(
f
,
pod
,
podName
,
containerName
,
buildBackOffDuration
)
By
(
"updating the image"
)
By
(
"updating the image"
)
pod
,
err
:=
podClient
.
Get
(
pod
.
Name
)
f
.
UpdatePod
(
podName
,
func
(
pod
*
api
.
Pod
)
{
if
err
!=
nil
{
framework
.
Failf
(
"failed to get pod: %v"
,
err
)
}
pod
.
Spec
.
Containers
[
0
]
.
Image
=
"gcr.io/google_containers/nginx-slim:0.7"
pod
.
Spec
.
Containers
[
0
]
.
Image
=
"gcr.io/google_containers/nginx-slim:0.7"
pod
,
err
=
podClient
.
Update
(
pod
)
})
if
err
!=
nil
{
framework
.
Failf
(
"error updating pod=%s/%s %v"
,
podName
,
containerName
,
err
)
}
time
.
Sleep
(
syncLoopFrequency
)
time
.
Sleep
(
syncLoopFrequency
)
framework
.
ExpectNoError
(
f
.
WaitForPodRunning
(
pod
.
Name
))
framework
.
ExpectNoError
(
f
.
WaitForPodRunning
(
pod
.
Name
))
...
...
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