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
1ec02b1c
Unverified
Commit
1ec02b1c
authored
Apr 27, 2018
by
liz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move path management from e2e_node to common test/utils directory
enables reuse of these methods for other e2e tests
parent
432b5422
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
59 deletions
+87
-59
build.go
test/e2e_node/builder/build.go
+4
-50
cadvisor_e2e.go
test/e2e_node/remote/cadvisor_e2e.go
+2
-3
node_conformance.go
test/e2e_node/remote/node_conformance.go
+3
-2
node_e2e.go
test/e2e_node/remote/node_e2e.go
+3
-2
run_local.go
test/e2e_node/runner/local/run_local.go
+3
-2
paths.go
test/utils/paths.go
+72
-0
No files found.
test/e2e_node/builder/build.go
View file @
1ec02b1c
...
...
@@ -22,10 +22,10 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"github.com/golang/glog"
"k8s.io/kubernetes/test/utils"
)
var
k8sBinDir
=
flag
.
String
(
"k8s-bin-dir"
,
""
,
"Directory containing k8s kubelet binaries."
)
...
...
@@ -39,7 +39,7 @@ var buildTargets = []string{
func
BuildGo
()
error
{
glog
.
Infof
(
"Building k8s binaries..."
)
k8sRoot
,
err
:=
GetK8sRootDir
()
k8sRoot
,
err
:=
utils
.
GetK8sRootDir
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to locate kubernetes root directory %v."
,
err
)
}
...
...
@@ -75,7 +75,7 @@ func getK8sBin(bin string) (string, error) {
return
filepath
.
Join
(
path
,
bin
),
nil
}
buildOutputDir
,
err
:=
GetK8sBuildOutputDir
()
buildOutputDir
,
err
:=
utils
.
GetK8sBuildOutputDir
()
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -84,53 +84,7 @@ func getK8sBin(bin string) (string, error) {
}
// Give up with error
return
""
,
fmt
.
Errorf
(
"Unable to locate %s. Can be defined using --k8s-path."
,
bin
)
}
// GetK8sRootDir returns the root directory for kubernetes, if present in the gopath.
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
_
,
testExec
,
_
,
_
:=
runtime
.
Caller
(
0
)
path
:=
filepath
.
Dir
(
testExec
)
// Look for the kubernetes source root directory
if
strings
.
Contains
(
path
,
"k8s.io/kubernetes"
)
{
splitPath
:=
strings
.
Split
(
path
,
"k8s.io/kubernetes"
)
return
splitPath
[
0
],
nil
}
return
""
,
fmt
.
Errorf
(
"Could not find kubernetes source root directory."
)
}
func
GetK8sBuildOutputDir
()
(
string
,
error
)
{
k8sRoot
,
err
:=
GetK8sRootDir
()
if
err
!=
nil
{
return
""
,
err
}
buildOutputDir
:=
filepath
.
Join
(
k8sRoot
,
"_output/local/go/bin"
)
if
_
,
err
:=
os
.
Stat
(
buildOutputDir
);
err
!=
nil
{
return
""
,
err
}
return
buildOutputDir
,
nil
return
""
,
fmt
.
Errorf
(
"unable to locate %s, Can be defined using --k8s-path"
,
bin
)
}
func
GetKubeletServerBin
()
string
{
...
...
test/e2e_node/remote/cadvisor_e2e.go
View file @
1ec02b1c
...
...
@@ -23,8 +23,7 @@ import (
"time"
"github.com/golang/glog"
"k8s.io/kubernetes/test/e2e_node/builder"
"k8s.io/kubernetes/test/utils"
)
// CAdvisorE2ERemote contains the specific functions in the cadvisor e2e test suite.
...
...
@@ -37,7 +36,7 @@ func InitCAdvisorE2ERemote() TestSuite {
// SetupTestPackage implements TestSuite.SetupTestPackage
func
(
n
*
CAdvisorE2ERemote
)
SetupTestPackage
(
tardir
,
systemSpecName
string
)
error
{
cadvisorRootDir
,
err
:=
builder
.
GetCAdvisorRootDir
()
cadvisorRootDir
,
err
:=
utils
.
GetCAdvisorRootDir
()
if
err
!=
nil
{
return
err
}
...
...
test/e2e_node/remote/node_conformance.go
View file @
1ec02b1c
...
...
@@ -28,6 +28,7 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/test/e2e_node/builder"
"k8s.io/kubernetes/test/utils"
)
// ConformanceRemote contains the specific functions in the node conformance test suite.
...
...
@@ -39,7 +40,7 @@ func InitConformanceRemote() TestSuite {
// getConformanceDirectory gets node conformance test build directory.
func
getConformanceDirectory
()
(
string
,
error
)
{
k8sRoot
,
err
:=
builder
.
GetK8sRootDir
()
k8sRoot
,
err
:=
utils
.
GetK8sRootDir
()
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -106,7 +107,7 @@ func (c *ConformanceRemote) SetupTestPackage(tardir, systemSpecName string) erro
}
// Make sure we can find the newly built binaries
buildOutputDir
,
err
:=
builder
.
GetK8sBuildOutputDir
()
buildOutputDir
,
err
:=
utils
.
GetK8sBuildOutputDir
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to locate kubernetes build output directory %v"
,
err
)
}
...
...
test/e2e_node/remote/node_e2e.go
View file @
1ec02b1c
...
...
@@ -27,6 +27,7 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/test/e2e_node/builder"
"k8s.io/kubernetes/test/utils"
)
const
(
...
...
@@ -49,12 +50,12 @@ func (n *NodeE2ERemote) SetupTestPackage(tardir, systemSpecName string) error {
}
// Make sure we can find the newly built binaries
buildOutputDir
,
err
:=
builder
.
GetK8sBuildOutputDir
()
buildOutputDir
,
err
:=
utils
.
GetK8sBuildOutputDir
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to locate kubernetes build output directory: %v"
,
err
)
}
rootDir
,
err
:=
builder
.
GetK8sRootDir
()
rootDir
,
err
:=
utils
.
GetK8sRootDir
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to locate kubernetes root directory: %v"
,
err
)
}
...
...
test/e2e_node/runner/local/run_local.go
View file @
1ec02b1c
...
...
@@ -25,6 +25,7 @@ import (
"strings"
"k8s.io/kubernetes/test/e2e_node/builder"
"k8s.io/kubernetes/test/utils"
"github.com/golang/glog"
)
...
...
@@ -49,7 +50,7 @@ func main() {
}
// Run node e2e test
outputDir
,
err
:=
builder
.
GetK8sBuildOutputDir
()
outputDir
,
err
:=
utils
.
GetK8sBuildOutputDir
()
if
err
!=
nil
{
glog
.
Fatalf
(
"Failed to get build output directory: %v"
,
err
)
}
...
...
@@ -59,7 +60,7 @@ func main() {
args
:=
[]
string
{
*
ginkgoFlags
,
test
,
"--"
,
*
testFlags
}
if
*
systemSpecName
!=
""
{
rootDir
,
err
:=
builder
.
GetK8sRootDir
()
rootDir
,
err
:=
utils
.
GetK8sRootDir
()
if
err
!=
nil
{
glog
.
Fatalf
(
"Failed to get k8s root directory: %v"
,
err
)
}
...
...
test/utils/paths.go
0 → 100644
View file @
1ec02b1c
/*
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
utils
import
(
"errors"
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
)
// GetK8sRootDir returns the root directory for kubernetes, if present in the gopath.
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
}
// RootDir gets the on-disk kubernetes source directory, returning an error is none is found
func
RootDir
()
(
string
,
error
)
{
// Get the directory of the current executable
_
,
testExec
,
_
,
_
:=
runtime
.
Caller
(
0
)
path
:=
filepath
.
Dir
(
testExec
)
// Look for the kubernetes source root directory
if
strings
.
Contains
(
path
,
"k8s.io/kubernetes"
)
{
splitPath
:=
strings
.
Split
(
path
,
"k8s.io/kubernetes"
)
return
splitPath
[
0
],
nil
}
return
""
,
errors
.
New
(
"could not find kubernetes source root directory"
)
}
// GetK8sBuildOutputDir returns the build output directory for k8s
func
GetK8sBuildOutputDir
()
(
string
,
error
)
{
k8sRoot
,
err
:=
GetK8sRootDir
()
if
err
!=
nil
{
return
""
,
err
}
buildOutputDir
:=
filepath
.
Join
(
k8sRoot
,
"_output/local/go/bin"
)
if
_
,
err
:=
os
.
Stat
(
buildOutputDir
);
err
!=
nil
{
return
""
,
err
}
return
buildOutputDir
,
nil
}
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