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
2cda7d29
Unverified
Commit
2cda7d29
authored
Mar 25, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 25, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75690 from oomichi/golint-e2e-framework-d-e
Fix golint failures of e2e/framework/[d-e]*.go
parents
1e36b6f4
65e6e465
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
18 deletions
+22
-18
deployment_util.go
test/e2e/framework/deployment_util.go
+12
-11
exec_util.go
test/e2e/framework/exec_util.go
+10
-7
No files found.
test/e2e/framework/deployment_util.go
View file @
2cda7d29
...
...
@@ -21,7 +21,7 @@ import (
"fmt"
"time"
.
"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo"
apps
"k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
...
...
@@ -30,19 +30,18 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
clientset
"k8s.io/client-go/kubernetes"
scaleclient
"k8s.io/client-go/scale"
watchtools
"k8s.io/client-go/tools/watch"
appsinternal
"k8s.io/kubernetes/pkg/apis/apps"
deploymentutil
"k8s.io/kubernetes/pkg/controller/deployment/util"
testutils
"k8s.io/kubernetes/test/utils"
imageutils
"k8s.io/kubernetes/test/utils/image"
)
// UpdateDeploymentWithRetries updates the specified deployment with retries.
func
UpdateDeploymentWithRetries
(
c
clientset
.
Interface
,
namespace
,
name
string
,
applyUpdate
testutils
.
UpdateDeploymentFunc
)
(
*
apps
.
Deployment
,
error
)
{
return
testutils
.
UpdateDeploymentWithRetries
(
c
,
namespace
,
name
,
applyUpdate
,
Logf
,
Poll
,
pollShortTimeout
)
}
// Waits for the deployment to clean up old rcs.
// Wait
ForDeploymentOldRSsNum wait
s for the deployment to clean up old rcs.
func
WaitForDeploymentOldRSsNum
(
c
clientset
.
Interface
,
ns
,
deploymentName
string
,
desiredRSNum
int
)
error
{
var
oldRSs
[]
*
apps
.
ReplicaSet
var
d
*
apps
.
Deployment
...
...
@@ -71,10 +70,12 @@ func logReplicaSetsOfDeployment(deployment *apps.Deployment, allOldRSs []*apps.R
testutils
.
LogReplicaSetsOfDeployment
(
deployment
,
allOldRSs
,
newRS
,
Logf
)
}
// WaitForObservedDeployment waits for the specified deployment generation.
func
WaitForObservedDeployment
(
c
clientset
.
Interface
,
ns
,
deploymentName
string
,
desiredGeneration
int64
)
error
{
return
testutils
.
WaitForObservedDeployment
(
c
,
ns
,
deploymentName
,
desiredGeneration
)
}
// WaitForDeploymentWithCondition waits for the specified deployment condition.
func
WaitForDeploymentWithCondition
(
c
clientset
.
Interface
,
ns
,
deploymentName
,
reason
string
,
condType
apps
.
DeploymentConditionType
)
error
{
return
testutils
.
WaitForDeploymentWithCondition
(
c
,
ns
,
deploymentName
,
reason
,
condType
,
Logf
,
Poll
,
pollLongTimeout
)
}
...
...
@@ -86,6 +87,7 @@ func WaitForDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName
return
testutils
.
WaitForDeploymentRevisionAndImage
(
c
,
ns
,
deploymentName
,
revision
,
image
,
Logf
,
Poll
,
pollLongTimeout
)
}
// NewDeployment returns a deployment spec with the specified argument.
func
NewDeployment
(
deploymentName
string
,
replicas
int32
,
podLabels
map
[
string
]
string
,
imageName
,
image
string
,
strategyType
apps
.
DeploymentStrategyType
)
*
apps
.
Deployment
{
zero
:=
int64
(
0
)
return
&
apps
.
Deployment
{
...
...
@@ -117,14 +119,14 @@ func NewDeployment(deploymentName string, replicas int32, podLabels map[string]s
}
}
// Waits for the deployment to complete, and don't check if rolling update strategy is broken.
// Wait
ForDeploymentComplete wait
s for the deployment to complete, and don't check if rolling update strategy is broken.
// Rolling update strategy is used only during a rolling update, and can be violated in other situations,
// such as shortly after a scaling event or the deployment is just created.
func
WaitForDeploymentComplete
(
c
clientset
.
Interface
,
d
*
apps
.
Deployment
)
error
{
return
testutils
.
WaitForDeploymentComplete
(
c
,
d
,
Logf
,
Poll
,
pollLongTimeout
)
}
// Waits for the deployment to complete, and check rolling update strategy isn't broken at any times.
// Wait
ForDeploymentCompleteAndCheckRolling wait
s for the deployment to complete, and check rolling update strategy isn't broken at any times.
// Rolling update strategy should not be broken during a rolling update.
func
WaitForDeploymentCompleteAndCheckRolling
(
c
clientset
.
Interface
,
d
*
apps
.
Deployment
)
error
{
return
testutils
.
WaitForDeploymentCompleteAndCheckRolling
(
c
,
d
,
Logf
,
Poll
,
pollLongTimeout
)
...
...
@@ -184,12 +186,9 @@ func WatchRecreateDeployment(c clientset.Interface, d *apps.Deployment) error {
return
err
}
func
ScaleDeployment
(
clientset
clientset
.
Interface
,
scalesGetter
scaleclient
.
ScalesGetter
,
ns
,
name
string
,
size
uint
,
wait
bool
)
error
{
return
ScaleResource
(
clientset
,
scalesGetter
,
ns
,
name
,
size
,
wait
,
appsinternal
.
Kind
(
"Deployment"
),
appsinternal
.
Resource
(
"deployments"
))
}
// RunDeployment runs a delopyment with the specified config.
func
RunDeployment
(
config
testutils
.
DeploymentConfig
)
error
{
By
(
fmt
.
Sprintf
(
"creating deployment %s in namespace %s"
,
config
.
Name
,
config
.
Namespace
))
ginkgo
.
By
(
fmt
.
Sprintf
(
"creating deployment %s in namespace %s"
,
config
.
Name
,
config
.
Namespace
))
config
.
NodeDumpFunc
=
DumpNodeDebugInfo
config
.
ContainerDumpFunc
=
LogFailedContainers
return
testutils
.
RunDeployment
(
config
)
...
...
@@ -199,6 +198,7 @@ func logPodsOfDeployment(c clientset.Interface, deployment *apps.Deployment, rsL
testutils
.
LogPodsOfDeployment
(
c
,
deployment
,
rsList
,
Logf
)
}
// WaitForDeploymentRevision waits for becoming the target revision of a delopyment.
func
WaitForDeploymentRevision
(
c
clientset
.
Interface
,
d
*
apps
.
Deployment
,
targetRevision
string
)
error
{
err
:=
wait
.
PollImmediate
(
Poll
,
pollLongTimeout
,
func
()
(
bool
,
error
)
{
deployment
,
err
:=
c
.
AppsV1
()
.
Deployments
(
d
.
Namespace
)
.
Get
(
d
.
Name
,
metav1
.
GetOptions
{})
...
...
@@ -219,6 +219,7 @@ func CheckDeploymentRevisionAndImage(c clientset.Interface, ns, deploymentName,
return
testutils
.
CheckDeploymentRevisionAndImage
(
c
,
ns
,
deploymentName
,
revision
,
image
)
}
// CreateDeployment creates a deployment.
func
CreateDeployment
(
client
clientset
.
Interface
,
replicas
int32
,
podLabels
map
[
string
]
string
,
nodeSelector
map
[
string
]
string
,
namespace
string
,
pvclaims
[]
*
v1
.
PersistentVolumeClaim
,
command
string
)
(
*
apps
.
Deployment
,
error
)
{
deploymentSpec
:=
MakeDeployment
(
replicas
,
podLabels
,
nodeSelector
,
namespace
,
pvclaims
,
false
,
command
)
deployment
,
err
:=
client
.
AppsV1
()
.
Deployments
(
namespace
)
.
Create
(
deploymentSpec
)
...
...
test/e2e/framework/exec_util.go
View file @
2cda7d29
...
...
@@ -28,7 +28,7 @@ import (
"k8s.io/client-go/tools/remotecommand"
"k8s.io/kubernetes/pkg/api/legacyscheme"
.
"github.com/onsi/gomega"
"github.com/onsi/gomega"
)
// ExecOptions passed to ExecWithOptions
...
...
@@ -107,30 +107,33 @@ func (f *Framework) ExecCommandInContainer(podName, containerName string, cmd ..
return
stdout
}
// ExecShellInContainer executes the specified command on the pod's container.
func
(
f
*
Framework
)
ExecShellInContainer
(
podName
,
containerName
string
,
cmd
string
)
string
{
return
f
.
ExecCommandInContainer
(
podName
,
containerName
,
"/bin/sh"
,
"-c"
,
cmd
)
}
func
(
f
*
Framework
)
E
xecCommandInPod
(
podName
string
,
cmd
...
string
)
string
{
func
(
f
*
Framework
)
e
xecCommandInPod
(
podName
string
,
cmd
...
string
)
string
{
pod
,
err
:=
f
.
PodClient
()
.
Get
(
podName
,
metav1
.
GetOptions
{})
ExpectNoError
(
err
,
"failed to get pod"
)
Expect
(
pod
.
Spec
.
Containers
)
.
NotTo
(
BeEmpty
())
gomega
.
Expect
(
pod
.
Spec
.
Containers
)
.
NotTo
(
gomega
.
BeEmpty
())
return
f
.
ExecCommandInContainer
(
podName
,
pod
.
Spec
.
Containers
[
0
]
.
Name
,
cmd
...
)
}
func
(
f
*
Framework
)
E
xecCommandInPodWithFullOutput
(
podName
string
,
cmd
...
string
)
(
string
,
string
,
error
)
{
func
(
f
*
Framework
)
e
xecCommandInPodWithFullOutput
(
podName
string
,
cmd
...
string
)
(
string
,
string
,
error
)
{
pod
,
err
:=
f
.
PodClient
()
.
Get
(
podName
,
metav1
.
GetOptions
{})
ExpectNoError
(
err
,
"failed to get pod"
)
Expect
(
pod
.
Spec
.
Containers
)
.
NotTo
(
BeEmpty
())
gomega
.
Expect
(
pod
.
Spec
.
Containers
)
.
NotTo
(
gomega
.
BeEmpty
())
return
f
.
ExecCommandInContainerWithFullOutput
(
podName
,
pod
.
Spec
.
Containers
[
0
]
.
Name
,
cmd
...
)
}
// ExecShellInPod executes the specified command on the pod.
func
(
f
*
Framework
)
ExecShellInPod
(
podName
string
,
cmd
string
)
string
{
return
f
.
E
xecCommandInPod
(
podName
,
"/bin/sh"
,
"-c"
,
cmd
)
return
f
.
e
xecCommandInPod
(
podName
,
"/bin/sh"
,
"-c"
,
cmd
)
}
// ExecShellInPodWithFullOutput executes the specified command on the pod with returing return stdout, stderr and error.
func
(
f
*
Framework
)
ExecShellInPodWithFullOutput
(
podName
string
,
cmd
string
)
(
string
,
string
,
error
)
{
return
f
.
E
xecCommandInPodWithFullOutput
(
podName
,
"/bin/sh"
,
"-c"
,
cmd
)
return
f
.
e
xecCommandInPodWithFullOutput
(
podName
,
"/bin/sh"
,
"-c"
,
cmd
)
}
func
execute
(
method
string
,
url
*
url
.
URL
,
config
*
restclient
.
Config
,
stdin
io
.
Reader
,
stdout
,
stderr
io
.
Writer
,
tty
bool
)
error
{
...
...
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