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
026a082a
Commit
026a082a
authored
Jul 31, 2017
by
Yang Guo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add node e2e test for Docker's shared PID namespace
parent
f189d7f7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
153 additions
and
21 deletions
+153
-21
BUILD
test/e2e_node/BUILD
+4
-1
docker_test.go
test/e2e_node/docker_test.go
+73
-0
docker_util.go
test/e2e_node/docker_util.go
+62
-0
garbage_collector_test.go
test/e2e_node/garbage_collector_test.go
+0
-2
image-config-serial.yaml
test/e2e_node/jenkins/image-config-serial.yaml
+5
-1
image-config.yaml
test/e2e_node/jenkins/image-config.yaml
+5
-1
security_context_test.go
test/e2e_node/security_context_test.go
+4
-16
No files found.
test/e2e_node/BUILD
View file @
026a082a
...
...
@@ -14,6 +14,7 @@ go_library(
"benchmark_util.go",
"container.go",
"doc.go",
"docker_util.go",
"gpus.go",
"image_list.go",
"node_problem_detector_linux.go",
...
...
@@ -39,6 +40,8 @@ go_library(
"//test/e2e/metrics:go_default_library",
"//test/e2e/perftype:go_default_library",
"//test/e2e_node/perftype:go_default_library",
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/github.com/docker/docker/client:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/google/cadvisor/client/v2:go_default_library",
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",
...
...
@@ -71,6 +74,7 @@ go_test(
"critical_pod_test.go",
"density_test.go",
"disk_eviction_test.go",
"docker_test.go",
"dockershim_checkpoint_test.go",
"dynamic_kubelet_configuration_test.go",
"e2e_node_suite_test.go",
...
...
@@ -118,7 +122,6 @@ go_test(
"//test/e2e_node/services:go_default_library",
"//test/e2e_node/system:go_default_library",
"//test/utils:go_default_library",
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/github.com/coreos/go-systemd/util:go_default_library",
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
...
...
test/e2e_node/docker_test.go
0 → 100644
View file @
026a082a
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
e2e_node
import
(
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/test/e2e/framework"
.
"github.com/onsi/ginkgo"
)
var
_
=
framework
.
KubeDescribe
(
"Docker features [Feature:Docker]"
,
func
()
{
f
:=
framework
.
NewDefaultFramework
(
"docker-feature-test"
)
BeforeEach
(
func
()
{
framework
.
RunIfContainerRuntimeIs
(
"docker"
)
})
Context
(
"when shared PID namespace is enabled"
,
func
()
{
It
(
"processes in different containers of the same pod should be able to see each other"
,
func
()
{
// TODO(yguo0905): Change this test to run unless the runtime is
// Docker and its version is <1.13.
By
(
"Check whether shared PID namespace is enabled."
)
isEnabled
,
err
:=
isSharedPIDNamespaceEnabled
()
framework
.
ExpectNoError
(
err
)
if
!
isEnabled
{
framework
.
Skipf
(
"Skipped because shared PID namespace is not enabled."
)
}
By
(
"Create a pod with two containers."
)
f
.
PodClient
()
.
CreateSync
(
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"shared-pid-ns-test-pod"
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
"test-container-1"
,
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Command
:
[]
string
{
"/bin/top"
},
},
{
Name
:
"test-container-2"
,
Image
:
"gcr.io/google_containers/busybox:1.24"
,
Command
:
[]
string
{
"/bin/sleep"
},
Args
:
[]
string
{
"10000"
},
},
},
},
})
By
(
"Check if the process in one container is visible to the process in the other."
)
pid1
:=
f
.
ExecCommandInContainer
(
"shared-pid-ns-test-pod"
,
"test-container-1"
,
"/bin/pidof"
,
"top"
)
pid2
:=
f
.
ExecCommandInContainer
(
"shared-pid-ns-test-pod"
,
"test-container-2"
,
"/bin/pidof"
,
"top"
)
if
pid1
!=
pid2
{
framework
.
Failf
(
"PIDs are not the same in different containers: test-container-1=%v, test-container-2=%v"
,
pid1
,
pid2
)
}
})
})
})
test/e2e_node/docker_util.go
0 → 100644
View file @
026a082a
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
e2e_node
import
(
"context"
"fmt"
"github.com/blang/semver"
"github.com/docker/docker/client"
)
const
(
defaultDockerEndpoint
=
"unix:///var/run/docker.sock"
)
// getDockerAPIVersion returns the Docker's API version.
func
getDockerAPIVersion
()
(
semver
.
Version
,
error
)
{
c
,
err
:=
client
.
NewClient
(
defaultDockerEndpoint
,
""
,
nil
,
nil
)
if
err
!=
nil
{
return
semver
.
Version
{},
fmt
.
Errorf
(
"failed to create docker client: %v"
,
err
)
}
version
,
err
:=
c
.
ServerVersion
(
context
.
Background
())
if
err
!=
nil
{
return
semver
.
Version
{},
fmt
.
Errorf
(
"failed to get docker info: %v"
,
err
)
}
return
semver
.
MustParse
(
version
.
APIVersion
+
".0"
),
nil
}
// isSharedPIDNamespaceEnabled returns true if the Docker version is 1.13.1+
// (API version 1.26+), and false otherwise.
func
isSharedPIDNamespaceEnabled
()
(
bool
,
error
)
{
version
,
err
:=
getDockerAPIVersion
()
if
err
!=
nil
{
return
false
,
err
}
return
version
.
GTE
(
semver
.
MustParse
(
"1.26.0"
)),
nil
}
// isDockerNoNewPrivilegesSupported returns true if Docker version is 1.11+
// (API version 1.23+), and false otherwise.
func
isDockerNoNewPrivilegesSupported
()
(
bool
,
error
)
{
version
,
err
:=
getDockerAPIVersion
()
if
err
!=
nil
{
return
false
,
err
}
return
version
.
GTE
(
semver
.
MustParse
(
"1.23.0"
)),
nil
}
test/e2e_node/garbage_collector_test.go
View file @
026a082a
...
...
@@ -32,8 +32,6 @@ import (
)
const
(
defaultDockerEndpoint
=
"unix:///var/run/docker.sock"
//TODO (dashpole): Once dynamic config is possible, test different values for maxPerPodContainer and maxContainers
// Currently using default values for maxPerPodContainer and maxTotalContainers
maxPerPodContainer
=
1
...
...
test/e2e_node/jenkins/image-config-serial.yaml
View file @
026a082a
...
...
@@ -12,7 +12,7 @@ images:
containervm
:
image
:
e2e-node-containervm-v20161208-image
# docker 1.11.2
project
:
kubernetes-node-e2e-images
gci
:
cos-stable
:
image_regex
:
cos-stable-59-9460-64-0
# docker 1.11.2
project
:
cos-cloud
metadata
:
"
user-data<test/e2e_node/jenkins/gci-init-gpu.yaml,gci-update-strategy=update_disabled"
...
...
@@ -20,3 +20,7 @@ images:
accelerators
:
-
type
:
nvidia-tesla-k80
count
:
2
cos-beta
:
image_regex
:
cos-beta-60-9592-70-0
# docker 1.13.1
project
:
cos-cloud
metadata
:
"
user-data<test/e2e_node/jenkins/gci-init.yaml,gci-update-strategy=update_disabled"
test/e2e_node/jenkins/image-config.yaml
View file @
026a082a
...
...
@@ -12,7 +12,11 @@ images:
containervm
:
image
:
e2e-node-containervm-v20161208-image
# docker 1.11.2
project
:
kubernetes-node-e2e-images
gci
:
cos-stable
:
image_regex
:
cos-stable-59-9460-64-0
# docker 1.11.2
project
:
cos-cloud
metadata
:
"
user-data<test/e2e_node/jenkins/gci-init.yaml,gci-update-strategy=update_disabled"
cos-beta
:
image_regex
:
cos-beta-60-9592-70-0
# docker 1.13.1
project
:
cos-cloud
metadata
:
"
user-data<test/e2e_node/jenkins/gci-init.yaml,gci-update-strategy=update_disabled"
test/e2e_node/security_context_test.go
View file @
026a082a
...
...
@@ -28,7 +28,6 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/test/e2e/framework"
"github.com/blang/semver"
.
"github.com/onsi/ginkgo"
)
...
...
@@ -381,21 +380,10 @@ var _ = framework.KubeDescribe("Security Context", func() {
BeforeEach
(
func
()
{
if
framework
.
TestContext
.
ContainerRuntime
==
"docker"
{
// parse the docker version
out
,
err
:=
exec
.
Command
(
"docker"
,
"-v"
)
.
CombinedOutput
()
if
err
!=
nil
{
framework
.
Failf
(
"checking docker version failed output %s: %v"
,
string
(
out
),
err
)
}
parts
:=
strings
.
Split
(
string
(
out
),
","
)
parts
=
strings
.
Split
(
parts
[
0
],
" "
)
dversion
:=
parts
[
len
(
parts
)
-
1
]
version
,
err
:=
semver
.
New
(
dversion
)
if
err
!=
nil
{
framework
.
Failf
(
"parsing docker version %q failed: %v"
,
dversion
,
err
)
}
if
version
.
LT
(
semver
.
Version
{
Major
:
1
,
Minor
:
11
})
{
// make sure its >= 1.11 thats when "no-new-privileges" was added
framework
.
Skipf
(
"Skipping no_new_privs tests, docker version is < 1.11 it is %s"
,
version
.
String
())
isSupported
,
err
:=
isDockerNoNewPrivilegesSupported
()
framework
.
ExpectNoError
(
err
)
if
!
isSupported
{
framework
.
Skipf
(
"Skipping because no_new_privs is not supported in this docker"
)
}
}
})
...
...
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