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
ec5ecb18
Commit
ec5ecb18
authored
Nov 20, 2015
by
Phillip Wittrock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial Pod e2e test
parent
0d4e0dc1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
33 deletions
+100
-33
known-flags.txt
hack/verify-flags/known-flags.txt
+3
-2
e2e_node_suite_test.go
test/e2e_node/e2e_node_suite_test.go
+3
-5
gcloud.go
test/e2e_node/gcloud/gcloud.go
+4
-3
kubelet_test.go
test/e2e_node/kubelet_test.go
+49
-20
run_e2e.go
test/e2e_node/runner/run_e2e.go
+4
-3
util.go
test/e2e_node/util.go
+37
-0
No files found.
hack/verify-flags/known-flags.txt
View file @
ec5ecb18
...
@@ -10,10 +10,10 @@ algorithm-provider
...
@@ -10,10 +10,10 @@ algorithm-provider
all-namespaces
all-namespaces
allocate-node-cidrs
allocate-node-cidrs
allow-privileged
allow-privileged
api-server-address
api-burst
api-burst
api-prefix
api-prefix
api-rate
api-rate
api-server-host
api-server-port
api-server-port
api-servers
api-servers
api-token
api-token
...
@@ -140,12 +140,12 @@ km-path
...
@@ -140,12 +140,12 @@ km-path
kube-api-burst
kube-api-burst
kube-api-qps
kube-api-qps
kubectl-path
kubectl-path
kubelet-address
kubelet-cadvisor-port
kubelet-cadvisor-port
kubelet-certificate-authority
kubelet-certificate-authority
kubelet-client-certificate
kubelet-client-certificate
kubelet-client-key
kubelet-client-key
kubelet-docker-endpoint
kubelet-docker-endpoint
kubelet-host
kubelet-host-network-sources
kubelet-host-network-sources
kubelet-https
kubelet-https
kubelet-network-plugin
kubelet-network-plugin
...
@@ -209,6 +209,7 @@ node-monitor-grace-period
...
@@ -209,6 +209,7 @@ node-monitor-grace-period
node-monitor-period
node-monitor-period
node-label
node-label
node-labels-file
node-labels-file
node-name
node-startup-grace-period
node-startup-grace-period
node-status-update-frequency
node-status-update-frequency
node-sync-period
node-sync-period
...
...
test/e2e_node/e2e_node_suite_test.go
View file @
ec5ecb18
...
@@ -24,11 +24,9 @@ import (
...
@@ -24,11 +24,9 @@ import (
"testing"
"testing"
)
)
var
kubeletHost
=
flag
.
String
(
"kubelet-host"
,
"localhost"
,
"Host address of the kubelet"
)
var
kubeletAddress
=
flag
.
String
(
"kubelet-address"
,
"localhost:10250"
,
"Host and port of the kubelet"
)
var
kubeletPort
=
flag
.
Int
(
"kubelet-port"
,
10250
,
"Kubelet port"
)
var
apiServerAddress
=
flag
.
String
(
"api-server-address"
,
"localhost:8080"
,
"Host and port of the api server"
)
var
nodeName
=
flag
.
String
(
"node-name"
,
""
,
"Name of the node"
)
var
apiServerHost
=
flag
.
String
(
"api-server-host"
,
"localhost"
,
"Host address of the api server"
)
var
apiServerPort
=
flag
.
Int
(
"api-server-port"
,
8080
,
"Api server port"
)
func
TestE2eNode
(
t
*
testing
.
T
)
{
func
TestE2eNode
(
t
*
testing
.
T
)
{
flag
.
Parse
()
flag
.
Parse
()
...
...
test/e2e_node/gcloud/gcloud.go
View file @
ec5ecb18
...
@@ -72,13 +72,14 @@ func (gc *gCloudClientImpl) Command(cmd string, moreargs ...string) ([]byte, err
...
@@ -72,13 +72,14 @@ func (gc *gCloudClientImpl) Command(cmd string, moreargs ...string) ([]byte, err
return
exec
.
Command
(
"gcloud"
,
args
...
)
.
CombinedOutput
()
return
exec
.
Command
(
"gcloud"
,
args
...
)
.
CombinedOutput
()
}
}
func
(
gc
*
gCloudClientImpl
)
TunnelCommand
(
sudo
bool
,
lPort
string
,
rPort
string
,
cmd
string
,
moreargs
...
string
)
([]
byte
,
error
)
{
func
(
gc
*
gCloudClientImpl
)
TunnelCommand
(
sudo
bool
,
lPort
string
,
rPort
string
,
dir
string
,
cmd
string
,
moreargs
...
string
)
([]
byte
,
error
)
{
tunnelStr
:=
fmt
.
Sprintf
(
"-L %s:localhost:%s"
,
lPort
,
rPort
)
tunnelStr
:=
fmt
.
Sprintf
(
"-L %s:localhost:%s"
,
lPort
,
rPort
)
args
:=
[]
string
{
"compute"
,
"ssh"
}
args
:=
[]
string
{
"compute"
,
"ssh"
}
if
gc
.
zone
!=
""
{
if
gc
.
zone
!=
""
{
args
=
append
(
args
,
"--zone"
,
gc
.
zone
)
args
=
append
(
args
,
"--zone"
,
gc
.
zone
)
}
}
args
=
append
(
args
,
"--ssh-flag"
,
tunnelStr
,
gc
.
host
,
"--"
)
args
=
append
(
args
,
"--ssh-flag"
,
tunnelStr
,
gc
.
host
,
"--"
)
args
=
append
(
args
,
"cd"
,
dir
,
";"
)
if
sudo
{
if
sudo
{
args
=
append
(
args
,
"sudo"
)
args
=
append
(
args
,
"sudo"
)
}
}
...
@@ -143,10 +144,10 @@ func (gc *gCloudClientImpl) CopyAndRun(sudo bool, remotePort string, bin string,
...
@@ -143,10 +144,10 @@ func (gc *gCloudClientImpl) CopyAndRun(sudo bool, remotePort string, bin string,
// Do the setup
// Do the setup
go
func
()
{
go
func
()
{
// Start the process
// Start the process
out
,
err
=
gc
.
TunnelCommand
(
sudo
,
h
.
LPort
,
remotePort
,
cmd
,
args
...
)
out
,
err
=
gc
.
TunnelCommand
(
sudo
,
h
.
LPort
,
remotePort
,
tDir
,
fmt
.
Sprintf
(
"./%s"
,
f
)
,
args
...
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"command failed %v"
,
err
)
glog
.
Errorf
(
"command failed %v"
,
err
)
h
.
Output
<-
RunResult
{
out
,
err
,
fmt
.
Sprintf
(
"%s %s"
,
cmd
,
strings
.
Join
(
args
,
" "
))}
h
.
Output
<-
RunResult
{
out
,
err
,
fmt
.
Sprintf
(
"%s %s"
,
f
,
strings
.
Join
(
args
,
" "
))}
return
return
}
}
}()
}()
...
...
test/e2e_node/kubelet_test.go
View file @
ec5ecb18
...
@@ -17,36 +17,65 @@ limitations under the License.
...
@@ -17,36 +17,65 @@ limitations under the License.
package
e2e_node
package
e2e_node
import
(
import
(
"bytes"
"fmt"
"fmt"
"io/ioutil"
"time"
"net/http"
"github.com/golang/glog"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
"k8s.io/kubernetes/pkg/api"
client
"k8s.io/kubernetes/pkg/client/unversioned"
)
)
var
_
=
Describe
(
"Kubelet"
,
func
()
{
var
_
=
Describe
(
"Kubelet"
,
func
()
{
var
cl
*
client
.
Client
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
// Setup the client to talk to the kubelet
// Setup the apiserver client
cl
=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
*
apiServerAddress
})
})
})
Describe
(
"checking kubelet status"
,
func
()
{
Describe
(
"pod scheduling"
,
func
()
{
Context
(
"when retrieving the node status"
,
func
()
{
Context
(
"when scheduling a busybox command in a pod"
,
func
()
{
It
(
"should have the container version"
,
func
()
{
It
(
"it should return succes"
,
func
()
{
pod
:=
&
api
.
Pod
{
// TODO: This is just a place holder, write a real test here
ObjectMeta
:
api
.
ObjectMeta
{
resp
,
err
:=
http
.
Get
(
fmt
.
Sprintf
(
"http://%s:%d/api/v2.0/attributes"
,
*
kubeletHost
,
*
kubeletPort
))
Name
:
"busybox"
,
if
err
!=
nil
{
Namespace
:
api
.
NamespaceDefault
,
glog
.
Errorf
(
"Error: %v"
,
err
)
},
return
Spec
:
api
.
PodSpec
{
}
NodeName
:
*
nodeName
,
defer
resp
.
Body
.
Close
()
Containers
:
[]
api
.
Container
{
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
{
if
err
!=
nil
{
Image
:
"busybox"
,
glog
.
Errorf
(
"Error: %v"
,
err
)
Name
:
"busybox"
,
return
Command
:
[]
string
{
"echo"
,
"'Hello World'"
},
ImagePullPolicy
:
"IfNotPresent"
,
},
},
},
}
}
glog
.
Infof
(
"Resp: %s"
,
body
)
_
,
err
:=
cl
.
Pods
(
api
.
NamespaceDefault
)
.
Create
(
pod
)
Expect
(
err
)
.
To
(
BeNil
(),
fmt
.
Sprintf
(
"Error creating Pod %v"
,
err
))
})
It
(
"it should print the output to logs"
,
func
()
{
errs
:=
Retry
(
time
.
Minute
*
3
,
time
.
Second
*
2
,
cl
,
func
(
cl
*
client
.
Client
)
error
{
rc
,
err
:=
cl
.
Pods
(
api
.
NamespaceDefault
)
.
GetLogs
(
"busybox"
,
&
api
.
PodLogOptions
{})
.
Stream
()
if
err
!=
nil
{
return
err
}
defer
rc
.
Close
()
buf
:=
new
(
bytes
.
Buffer
)
buf
.
ReadFrom
(
rc
)
Expect
(
buf
.
String
())
.
To
(
Equal
(
"'Hello World'
\n
"
))
return
nil
})
Expect
(
errs
)
.
To
(
BeEmpty
(),
fmt
.
Sprintf
(
"Failed to get Logs"
))
})
It
(
"it should be possible to delete"
,
func
()
{
err
:=
cl
.
Pods
(
api
.
NamespaceDefault
)
.
Delete
(
"busybox"
,
&
api
.
DeleteOptions
{})
Expect
(
err
)
.
To
(
BeNil
(),
fmt
.
Sprintf
(
"Error creating Pod %v"
,
err
))
})
})
})
})
})
})
...
...
test/e2e_node/runner/run_e2e.go
View file @
ec5ecb18
...
@@ -96,7 +96,7 @@ func main() {
...
@@ -96,7 +96,7 @@ func main() {
// Wait for the tests to finish
// Wait for the tests to finish
w
.
Wait
()
w
.
Wait
()
glog
.
Infof
(
"
All hosts finished
"
)
glog
.
Infof
(
"
Done
"
)
}
}
func
WaitForUser
()
{
func
WaitForUser
()
{
...
@@ -148,7 +148,8 @@ func runTests(host string) ([]byte, error) {
...
@@ -148,7 +148,8 @@ func runTests(host string) ([]byte, error) {
ginkoTests
:=
filepath
.
Join
(
kubeRoot
,
ginkoTestRelPath
)
ginkoTests
:=
filepath
.
Join
(
kubeRoot
,
ginkoTestRelPath
)
return
exec
.
Command
(
return
exec
.
Command
(
"ginkgo"
,
ginkoTests
,
"--"
,
"ginkgo"
,
ginkoTests
,
"--"
,
"--kubelet-host"
,
"localhost"
,
"--kubelet-port"
,
kh
.
LPort
,
"--kubelet-address"
,
fmt
.
Sprintf
(
"http://localhost:%s"
,
kh
.
LPort
),
"--api-server-host"
,
"localhost"
,
"--api-server-port"
,
kh
.
LPort
,
"--api-server-address"
,
fmt
.
Sprintf
(
"http://localhost:%s"
,
ah
.
LPort
),
"--node-name"
,
host
,
"-logtostderr"
)
.
CombinedOutput
()
"-logtostderr"
)
.
CombinedOutput
()
}
}
test/e2e_node/util.go
0 → 100644
View file @
ec5ecb18
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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
(
"time"
client
"k8s.io/kubernetes/pkg/client/unversioned"
)
type
RetryFn
func
(
cl
*
client
.
Client
)
error
func
Retry
(
maxWait
time
.
Duration
,
wait
time
.
Duration
,
cl
*
client
.
Client
,
retry
RetryFn
)
[]
error
{
errs
:=
[]
error
{}
for
start
:=
time
.
Now
();
time
.
Now
()
.
Before
(
start
.
Add
(
maxWait
));
{
if
err
:=
retry
(
cl
);
err
!=
nil
{
errs
=
append
(
errs
,
err
)
}
else
{
return
[]
error
{}
}
}
return
errs
}
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