mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 22:53:22 +00:00
Add an e2e test for exec liveness probes. Fix the docker exec integration.
This commit is contained in:
@@ -92,8 +92,8 @@ type dockerContainerCommandRunner struct {
|
||||
client DockerInterface
|
||||
}
|
||||
|
||||
// The first version of docker that supports exec natively is 1.3.0
|
||||
var dockerVersionWithExec = []uint{1, 3, 0}
|
||||
// The first version of docker that supports exec natively is 1.3.0 == API 1.15
|
||||
var dockerAPIVersionWithExec = []uint{1, 15}
|
||||
|
||||
// Returns the major and minor version numbers of docker server.
|
||||
func (d *dockerContainerCommandRunner) getDockerServerVersion() ([]uint, error) {
|
||||
@@ -103,7 +103,7 @@ func (d *dockerContainerCommandRunner) getDockerServerVersion() ([]uint, error)
|
||||
}
|
||||
version := []uint{}
|
||||
for _, entry := range *env {
|
||||
if strings.Contains(strings.ToLower(entry), "server version") {
|
||||
if strings.Contains(strings.ToLower(entry), "apiversion") || strings.Contains(strings.ToLower(entry), "api version") {
|
||||
elems := strings.Split(strings.Split(entry, "=")[1], ".")
|
||||
for _, elem := range elems {
|
||||
val, err := strconv.ParseUint(elem, 10, 32)
|
||||
@@ -123,10 +123,10 @@ func (d *dockerContainerCommandRunner) nativeExecSupportExists() (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if len(dockerVersionWithExec) != len(version) {
|
||||
return false, fmt.Errorf("unexpected docker version format. Expecting %v format, got %v", dockerVersionWithExec, version)
|
||||
if len(dockerAPIVersionWithExec) != len(version) {
|
||||
return false, fmt.Errorf("unexpected docker version format. Expecting %v format, got %v", dockerAPIVersionWithExec, version)
|
||||
}
|
||||
for idx, val := range dockerVersionWithExec {
|
||||
for idx, val := range dockerAPIVersionWithExec {
|
||||
if version[idx] < val {
|
||||
return false, nil
|
||||
}
|
||||
|
@@ -130,7 +130,7 @@ func TestGetDockerServerVersion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("got error while getting docker server version - %s", err)
|
||||
}
|
||||
expectedVersion := []uint{1, 1, 3}
|
||||
expectedVersion := []uint{1, 15}
|
||||
if len(expectedVersion) != len(version) {
|
||||
t.Errorf("invalid docker server version. expected: %v, got: %v", expectedVersion, version)
|
||||
} else {
|
||||
@@ -155,7 +155,7 @@ func TestExecSupportExists(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecSupportNotExists(t *testing.T) {
|
||||
fakeDocker := &FakeDockerClient{VersionInfo: docker.Env{"Client version=1.2", "Server version=1.1.2", "Server API version=1.15"}}
|
||||
fakeDocker := &FakeDockerClient{VersionInfo: docker.Env{"Client version=1.2", "Server version=1.1.2", "Server API version=1.14"}}
|
||||
runner := dockerContainerCommandRunner{fakeDocker}
|
||||
useNativeExec, _ := runner.nativeExecSupportExists()
|
||||
if useNativeExec {
|
||||
|
Reference in New Issue
Block a user