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
17e8d8c0
Commit
17e8d8c0
authored
Jan 31, 2018
by
David Ashpole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use node-e2e framework for testing cadvisor
parent
1150de9c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
113 additions
and
11 deletions
+113
-11
test-e2e-node.sh
hack/make-rules/test-e2e-node.sh
+2
-0
build.go
test/e2e_node/builder/build.go
+21
-2
BUILD
test/e2e_node/remote/BUILD
+1
-0
cadvisor_e2e.go
test/e2e_node/remote/cadvisor_e2e.go
+77
-0
remote.go
test/e2e_node/remote/remote.go
+8
-9
types.go
test/e2e_node/remote/types.go
+2
-0
run_remote.go
test/e2e_node/runner/remote/run_remote.go
+2
-0
No files found.
hack/make-rules/test-e2e-node.sh
View file @
17e8d8c0
...
@@ -93,6 +93,7 @@ if [ $remote = true ] ; then
...
@@ -93,6 +93,7 @@ if [ $remote = true ] ; then
instance_prefix
=
${
INSTANCE_PREFIX
:-
"test"
}
instance_prefix
=
${
INSTANCE_PREFIX
:-
"test"
}
cleanup
=
${
CLEANUP
:-
"true"
}
cleanup
=
${
CLEANUP
:-
"true"
}
delete_instances
=
${
DELETE_INSTANCES
:-
"false"
}
delete_instances
=
${
DELETE_INSTANCES
:-
"false"
}
test_suite
=
${
TEST_SUITE
:-
"default"
}
# Get the compute zone
# Get the compute zone
zone
=
$(
gcloud info
--format
=
'value(config.properties.compute.zone)'
)
zone
=
$(
gcloud info
--format
=
'value(config.properties.compute.zone)'
)
...
@@ -147,6 +148,7 @@ if [ $remote = true ] ; then
...
@@ -147,6 +148,7 @@ if [ $remote = true ] ; then
--image-project
=
"
$image_project
"
--instance-name-prefix
=
"
$instance_prefix
"
\
--image-project
=
"
$image_project
"
--instance-name-prefix
=
"
$instance_prefix
"
\
--delete-instances
=
"
$delete_instances
"
--test_args
=
"
$test_args
"
--instance-metadata
=
"
$metadata
"
\
--delete-instances
=
"
$delete_instances
"
--test_args
=
"
$test_args
"
--instance-metadata
=
"
$metadata
"
\
--image-config-file
=
"
$image_config_file
"
--system-spec-name
=
"
$system_spec_name
"
\
--image-config-file
=
"
$image_config_file
"
--system-spec-name
=
"
$system_spec_name
"
\
--test-suite
=
"
$test_suite
"
\
2>&1 |
tee
-i
"
${
artifacts
}
/build-log.txt"
2>&1 |
tee
-i
"
${
artifacts
}
/build-log.txt"
exit
$?
exit
$?
...
...
test/e2e_node/builder/build.go
View file @
17e8d8c0
...
@@ -87,8 +87,27 @@ func getK8sBin(bin string) (string, error) {
...
@@ -87,8 +87,27 @@ func getK8sBin(bin string) (string, error) {
return
""
,
fmt
.
Errorf
(
"Unable to locate %s. Can be defined using --k8s-path."
,
bin
)
return
""
,
fmt
.
Errorf
(
"Unable to locate %s. Can be defined using --k8s-path."
,
bin
)
}
}
//
TODO: Dedup / merge this with comparable utilities in e2e/util.go
//
GetK8sRootDir returns the root directory for kubernetes, if present in the gopath.
func
GetK8sRootDir
()
(
string
,
error
)
{
func
GetK8sRootDir
()
(
string
,
error
)
{
dir
,
err
:=
RootDir
()
if
err
!=
nil
{
return
""
,
err
}
return
filepath
.
Join
(
dir
,
fmt
.
Sprintf
(
"%s/"
,
"k8s.io/kubernetes"
)),
nil
}
// GetCAdvisorRootDir returns the root directory for cAdvisor, if present in the gopath.
func
GetCAdvisorRootDir
()
(
string
,
error
)
{
dir
,
err
:=
RootDir
()
if
err
!=
nil
{
return
""
,
err
}
return
filepath
.
Join
(
dir
,
fmt
.
Sprintf
(
"%s/"
,
"github.com/google/cadvisor"
)),
nil
}
// TODO: Dedup / merge this with comparable utilities in e2e/util.go
// RootDir returns the path to the directory containing the k8s.io directory
func
RootDir
()
(
string
,
error
)
{
// Get the directory of the current executable
// Get the directory of the current executable
_
,
testExec
,
_
,
_
:=
runtime
.
Caller
(
0
)
_
,
testExec
,
_
,
_
:=
runtime
.
Caller
(
0
)
path
:=
filepath
.
Dir
(
testExec
)
path
:=
filepath
.
Dir
(
testExec
)
...
@@ -96,7 +115,7 @@ func GetK8sRootDir() (string, error) {
...
@@ -96,7 +115,7 @@ func GetK8sRootDir() (string, error) {
// Look for the kubernetes source root directory
// Look for the kubernetes source root directory
if
strings
.
Contains
(
path
,
"k8s.io/kubernetes"
)
{
if
strings
.
Contains
(
path
,
"k8s.io/kubernetes"
)
{
splitPath
:=
strings
.
Split
(
path
,
"k8s.io/kubernetes"
)
splitPath
:=
strings
.
Split
(
path
,
"k8s.io/kubernetes"
)
return
filepath
.
Join
(
splitPath
[
0
],
"k8s.io/kubernetes/"
)
,
nil
return
splitPath
[
0
]
,
nil
}
}
return
""
,
fmt
.
Errorf
(
"Could not find kubernetes source root directory."
)
return
""
,
fmt
.
Errorf
(
"Could not find kubernetes source root directory."
)
...
...
test/e2e_node/remote/BUILD
View file @
17e8d8c0
...
@@ -8,6 +8,7 @@ load(
...
@@ -8,6 +8,7 @@ load(
go_library(
go_library(
name = "go_default_library",
name = "go_default_library",
srcs = [
srcs = [
"cadvisor_e2e.go",
"node_conformance.go",
"node_conformance.go",
"node_e2e.go",
"node_e2e.go",
"remote.go",
"remote.go",
...
...
test/e2e_node/remote/cadvisor_e2e.go
0 → 100644
View file @
17e8d8c0
/*
Copyright 2018 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
remote
import
(
"fmt"
"os"
"os/exec"
"time"
"github.com/golang/glog"
"k8s.io/kubernetes/test/e2e_node/builder"
)
// CAdvisorE2ERemote contains the specific functions in the cadvisor e2e test suite.
type
CAdvisorE2ERemote
struct
{}
// InitCAdvisorE2ERemote performs initialization for cadvisor remote testing
func
InitCAdvisorE2ERemote
()
TestSuite
{
return
&
CAdvisorE2ERemote
{}
}
// SetupTestPackage implements TestSuite.SetupTestPackage
func
(
n
*
CAdvisorE2ERemote
)
SetupTestPackage
(
tardir
,
systemSpecName
string
)
error
{
cadvisorRootDir
,
err
:=
builder
.
GetCAdvisorRootDir
()
if
err
!=
nil
{
return
err
}
// build the cadvisor binary and tests
if
err
:=
runCommand
(
fmt
.
Sprintf
(
"%s/build/prow_e2e.sh"
,
cadvisorRootDir
));
err
!=
nil
{
return
err
}
// transfer the entire directory to each node
if
err
:=
runCommand
(
"cp"
,
"-R"
,
cadvisorRootDir
,
fmt
.
Sprintf
(
"%s/"
,
tardir
));
err
!=
nil
{
return
err
}
return
nil
}
func
runCommand
(
command
string
,
args
...
string
)
error
{
cmd
:=
exec
.
Command
(
command
,
args
...
)
cmd
.
Stdout
=
os
.
Stdout
cmd
.
Stderr
=
os
.
Stderr
err
:=
cmd
.
Run
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to run command %s. error: %v"
,
command
,
err
)
}
return
nil
}
// RunTest implements TestSuite.RunTest
func
(
n
*
CAdvisorE2ERemote
)
RunTest
(
host
,
workspace
,
results
,
imageDesc
,
junitFilePrefix
,
testArgs
,
ginkgoArgs
,
systemSpecName
string
,
timeout
time
.
Duration
)
(
string
,
error
)
{
// Kill any running node processes
cleanupNodeProcesses
(
host
)
glog
.
V
(
2
)
.
Infof
(
"Starting tests on %q"
,
host
)
return
SSH
(
host
,
"sh"
,
"-c"
,
getSSHCommand
(
" && "
,
fmt
.
Sprintf
(
"cd %s/cadvisor"
,
workspace
),
fmt
.
Sprintf
(
"timeout -k 30s %fs ./build/integration.sh ../results/cadvisor.log"
,
timeout
.
Seconds
()),
))
}
test/e2e_node/remote/remote.go
View file @
17e8d8c0
...
@@ -139,21 +139,20 @@ func getTestArtifacts(host, testDir string) error {
...
@@ -139,21 +139,20 @@ func getTestArtifacts(host, testDir string) error {
return
fmt
.
Errorf
(
"failed to create log directory %q: %v"
,
logPath
,
err
)
return
fmt
.
Errorf
(
"failed to create log directory %q: %v"
,
logPath
,
err
)
}
}
// Copy logs to artifacts/hostname
// Copy logs to artifacts/hostname
_
,
err
:=
runSSHCommand
(
"scp"
,
"-r"
,
fmt
.
Sprintf
(
"%s:%s/results/*.log"
,
GetHostnameOrIp
(
host
),
testDir
),
logPath
)
if
_
,
err
:=
runSSHCommand
(
"scp"
,
"-r"
,
fmt
.
Sprintf
(
"%s:%s/results/*.log"
,
GetHostnameOrIp
(
host
),
testDir
),
logPath
);
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
// Copy json files (if any) to artifacts.
// Copy json files (if any) to artifacts.
if
_
,
err
=
SSH
(
host
,
"ls"
,
fmt
.
Sprintf
(
"%s/results/*.json"
,
testDir
));
err
==
nil
{
if
_
,
err
:=
SSH
(
host
,
"ls"
,
fmt
.
Sprintf
(
"%s/results/*.json"
,
testDir
));
err
==
nil
{
_
,
err
=
runSSHCommand
(
"scp"
,
"-r"
,
fmt
.
Sprintf
(
"%s:%s/results/*.json"
,
GetHostnameOrIp
(
host
),
testDir
),
*
resultsDir
)
if
_
,
err
=
runSSHCommand
(
"scp"
,
"-r"
,
fmt
.
Sprintf
(
"%s:%s/results/*.json"
,
GetHostnameOrIp
(
host
),
testDir
),
*
resultsDir
);
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
}
// Copy junit to the top of artifacts
if
_
,
err
:=
SSH
(
host
,
"ls"
,
fmt
.
Sprintf
(
"%s/results/junit*"
,
testDir
));
err
==
nil
{
_
,
err
=
runSSHCommand
(
"scp"
,
fmt
.
Sprintf
(
"%s:%s/results/junit*"
,
GetHostnameOrIp
(
host
),
testDir
),
*
resultsDir
)
// Copy junit (if any) to the top of artifacts
if
err
!=
nil
{
if
_
,
err
=
runSSHCommand
(
"scp"
,
fmt
.
Sprintf
(
"%s:%s/results/junit*"
,
GetHostnameOrIp
(
host
),
testDir
),
*
resultsDir
);
err
!=
nil
{
return
err
return
err
}
}
}
return
nil
return
nil
}
}
...
...
test/e2e_node/remote/types.go
View file @
17e8d8c0
...
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
...
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
// Package remote contains implementations of the TestSuite interface, which specify
// how to run various node test suites remotely.
package
remote
package
remote
import
(
import
(
...
...
test/e2e_node/runner/remote/run_remote.go
View file @
17e8d8c0
...
@@ -178,6 +178,8 @@ func main() {
...
@@ -178,6 +178,8 @@ func main() {
switch
*
testSuite
{
switch
*
testSuite
{
case
"conformance"
:
case
"conformance"
:
suite
=
remote
.
InitConformanceRemote
()
suite
=
remote
.
InitConformanceRemote
()
case
"cadvisor"
:
suite
=
remote
.
InitCAdvisorE2ERemote
()
// TODO: Add subcommand for node soaking, node conformance, cri validation.
// TODO: Add subcommand for node soaking, node conformance, cri validation.
case
"default"
:
case
"default"
:
// Use node e2e suite by default if no subcommand is specified.
// Use node e2e suite by default if no subcommand is specified.
...
...
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