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
8e23c656
Commit
8e23c656
authored
Jun 06, 2017
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add testmain setup func to the integration framework
parent
3f59f213
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
130 additions
and
14 deletions
+130
-14
WORKSPACE
build/root/WORKSPACE
+10
-0
etcd_storage_path_test.go
test/integration/etcd/etcd_storage_path_test.go
+1
-1
apiserver_test.go
test/integration/examples/apiserver_test.go
+3
-3
api.go
test/integration/federation/framework/api.go
+1
-1
BUILD
test/integration/framework/BUILD
+4
-0
etcd.go
test/integration/framework/etcd.go
+109
-0
master_utils.go
test/integration/framework/master_utils.go
+1
-9
etcd.BUILD
third_party/etcd.BUILD
+1
-0
No files found.
build/root/WORKSPACE
View file @
8e23c656
...
@@ -12,6 +12,16 @@ http_archive(
...
@@ -12,6 +12,16 @@ http_archive(
urls = ["https://github.com/kubernetes/repo-infra/archive/9dedd5f4093884c133ad5ea73695b28338b954ab.tar.gz"],
urls = ["https://github.com/kubernetes/repo-infra/archive/9dedd5f4093884c133ad5ea73695b28338b954ab.tar.gz"],
)
)
ETCD_VERSION = "3.0.17"
new_http_archive(
name = "com_coreos_etcd",
build_file = "third_party/etcd.BUILD",
sha256 = "274c46a7f8d26f7ae99d6880610f54933cbcf7f3beafa19236c52eb5df8c7a0b",
strip_prefix = "etcd-v%s-linux-amd64" % ETCD_VERSION,
urls = ["https://github.com/coreos/etcd/releases/download/v%s/etcd-v%s-linux-amd64.tar.gz" % (ETCD_VERSION, ETCD_VERSION)],
)
# This contains a patch to not prepend ./ to tarfiles produced by pkg_tar.
# This contains a patch to not prepend ./ to tarfiles produced by pkg_tar.
# When merged upstream, we'll no longer need to use ixdy's fork:
# When merged upstream, we'll no longer need to use ixdy's fork:
# https://bazel-review.googlesource.com/#/c/10390/
# https://bazel-review.googlesource.com/#/c/10390/
...
...
test/integration/etcd/etcd_storage_path_test.go
View file @
8e23c656
...
@@ -588,7 +588,7 @@ func startRealMasterOrDie(t *testing.T, certDir string) (*allClient, clientv3.KV
...
@@ -588,7 +588,7 @@ func startRealMasterOrDie(t *testing.T, certDir string) (*allClient, clientv3.KV
kubeAPIServerOptions
:=
options
.
NewServerRunOptions
()
kubeAPIServerOptions
:=
options
.
NewServerRunOptions
()
kubeAPIServerOptions
.
SecureServing
.
BindAddress
=
net
.
ParseIP
(
"127.0.0.1"
)
kubeAPIServerOptions
.
SecureServing
.
BindAddress
=
net
.
ParseIP
(
"127.0.0.1"
)
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
FromEnv
()}
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
()}
kubeAPIServerOptions
.
Etcd
.
DefaultStorageMediaType
=
runtime
.
ContentTypeJSON
// TODO use protobuf?
kubeAPIServerOptions
.
Etcd
.
DefaultStorageMediaType
=
runtime
.
ContentTypeJSON
// TODO use protobuf?
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
Authorization
.
Mode
=
"RBAC"
kubeAPIServerOptions
.
Authorization
.
Mode
=
"RBAC"
...
...
test/integration/examples/apiserver_test.go
View file @
8e23c656
...
@@ -102,7 +102,7 @@ func TestAggregatedAPIServer(t *testing.T) {
...
@@ -102,7 +102,7 @@ func TestAggregatedAPIServer(t *testing.T) {
kubeAPIServerOptions
.
SecureServing
.
BindPort
=
kubePort
kubeAPIServerOptions
.
SecureServing
.
BindPort
=
kubePort
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
SecureServing
.
ServerCert
.
CertDirectory
=
certDir
kubeAPIServerOptions
.
InsecureServing
.
BindPort
=
0
kubeAPIServerOptions
.
InsecureServing
.
BindPort
=
0
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
FromEnv
()}
kubeAPIServerOptions
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
()}
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
ServiceClusterIPRange
=
*
defaultServiceClusterIPRange
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
UsernameHeaders
=
[]
string
{
"X-Remote-User"
}
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
UsernameHeaders
=
[]
string
{
"X-Remote-User"
}
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
GroupHeaders
=
[]
string
{
"X-Remote-Group"
}
kubeAPIServerOptions
.
Authentication
.
RequestHeader
.
GroupHeaders
=
[]
string
{
"X-Remote-Group"
}
...
@@ -190,7 +190,7 @@ func TestAggregatedAPIServer(t *testing.T) {
...
@@ -190,7 +190,7 @@ func TestAggregatedAPIServer(t *testing.T) {
"--requestheader-allowed-names=kube-aggregator"
,
"--requestheader-allowed-names=kube-aggregator"
,
"--authentication-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--authentication-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--authorization-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--authorization-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--etcd-servers"
,
framework
.
GetEtcdURL
FromEnv
(),
"--etcd-servers"
,
framework
.
GetEtcdURL
(),
"--cert-dir"
,
wardleCertDir
,
"--cert-dir"
,
wardleCertDir
,
})
})
if
err
:=
wardleCmd
.
Execute
();
err
!=
nil
{
if
err
:=
wardleCmd
.
Execute
();
err
!=
nil
{
...
@@ -266,7 +266,7 @@ func TestAggregatedAPIServer(t *testing.T) {
...
@@ -266,7 +266,7 @@ func TestAggregatedAPIServer(t *testing.T) {
"--core-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--core-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--authentication-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--authentication-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--authorization-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--authorization-kubeconfig"
,
kubeconfigFile
.
Name
(),
"--etcd-servers"
,
framework
.
GetEtcdURL
FromEnv
(),
"--etcd-servers"
,
framework
.
GetEtcdURL
(),
"--cert-dir"
,
aggregatorCertDir
,
"--cert-dir"
,
aggregatorCertDir
,
})
})
if
err
:=
aggregatorCmd
.
Execute
();
err
!=
nil
{
if
err
:=
aggregatorCmd
.
Execute
();
err
!=
nil
{
...
...
test/integration/federation/framework/api.go
View file @
8e23c656
...
@@ -36,7 +36,7 @@ const apiNoun = "federation apiserver"
...
@@ -36,7 +36,7 @@ const apiNoun = "federation apiserver"
// GetRunOptions returns the default run options that can be used to run a test federation apiserver.
// GetRunOptions returns the default run options that can be used to run a test federation apiserver.
func
GetRunOptions
()
*
options
.
ServerRunOptions
{
func
GetRunOptions
()
*
options
.
ServerRunOptions
{
r
:=
options
.
NewServerRunOptions
()
r
:=
options
.
NewServerRunOptions
()
r
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
FromEnv
()}
r
.
Etcd
.
StorageConfig
.
ServerList
=
[]
string
{
framework
.
GetEtcdURL
()}
// Use a unique prefix to ensure isolation from other tests using the same etcd instance
// Use a unique prefix to ensure isolation from other tests using the same etcd instance
r
.
Etcd
.
StorageConfig
.
Prefix
=
uuid
.
New
()
r
.
Etcd
.
StorageConfig
.
Prefix
=
uuid
.
New
()
// Disable secure serving
// Disable secure serving
...
...
test/integration/framework/BUILD
View file @
8e23c656
...
@@ -10,10 +10,14 @@ load(
...
@@ -10,10 +10,14 @@ load(
go_library(
go_library(
name = "go_default_library",
name = "go_default_library",
srcs = [
srcs = [
"etcd.go",
"master_utils.go",
"master_utils.go",
"perf_utils.go",
"perf_utils.go",
"serializer.go",
"serializer.go",
],
],
data = [
"@com_coreos_etcd//:etcd",
],
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//pkg/api:go_default_library",
"//pkg/api:go_default_library",
...
...
test/integration/framework/etcd.go
0 → 100644
View file @
8e23c656
/*
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
framework
import
(
"fmt"
"hash/adler32"
"io"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"path/filepath"
"sync"
"k8s.io/kubernetes/pkg/util/env"
"github.com/golang/glog"
)
var
(
etcdSetup
sync
.
Once
etcdURL
=
""
)
func
setupETCD
()
{
etcdSetup
.
Do
(
func
()
{
if
os
.
Getenv
(
"RUNFILES_DIR"
)
==
""
{
etcdURL
=
env
.
GetEnvAsStringOrFallback
(
"KUBE_INTEGRATION_ETCD_URL"
,
"http://127.0.0.1:2379"
)
return
}
etcdPath
:=
filepath
.
Join
(
os
.
Getenv
(
"RUNFILES_DIR"
),
"com_coreos_etcd/etcd"
)
// give every test the same random port each run
etcdPort
:=
20000
+
rand
.
New
(
rand
.
NewSource
(
int64
(
adler32
.
Checksum
([]
byte
(
os
.
Args
[
0
])))))
.
Intn
(
5000
)
etcdURL
=
fmt
.
Sprintf
(
"http://127.0.0.1:%d"
,
etcdPort
)
info
,
err
:=
os
.
Stat
(
etcdPath
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Unable to stat etcd: %v"
,
err
)
}
if
info
.
IsDir
()
{
glog
.
Fatalf
(
"Did not expect %q to be a directory"
,
etcdPath
)
}
etcdDataDir
,
err
:=
ioutil
.
TempDir
(
os
.
TempDir
(),
"integration_test_etcd_data"
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Unable to make temp etcd data dir: %v"
,
err
)
}
glog
.
Infof
(
"storing etcd data in: %v"
,
etcdDataDir
)
etcdCmd
:=
exec
.
Command
(
etcdPath
,
"--data-dir"
,
etcdDataDir
,
"--listen-client-urls"
,
GetEtcdURL
(),
"--advertise-client-urls"
,
GetEtcdURL
(),
"--listen-peer-urls"
,
"http://127.0.0.1:0"
,
)
stdout
,
err
:=
etcdCmd
.
StdoutPipe
()
if
err
!=
nil
{
glog
.
Fatalf
(
"Failed to run etcd: %v"
,
err
)
}
stderr
,
err
:=
etcdCmd
.
StderrPipe
()
if
err
!=
nil
{
glog
.
Fatalf
(
"Failed to run etcd: %v"
,
err
)
}
if
err
:=
etcdCmd
.
Start
();
err
!=
nil
{
glog
.
Fatalf
(
"Failed to run etcd: %v"
,
err
)
}
go
io
.
Copy
(
os
.
Stdout
,
stdout
)
go
io
.
Copy
(
os
.
Stderr
,
stderr
)
go
func
()
{
if
err
:=
etcdCmd
.
Wait
();
err
!=
nil
{
glog
.
Fatalf
(
"Failed to run etcd: %v"
,
err
)
}
glog
.
Fatalf
(
"etcd should not have succeeded"
)
}()
})
}
func
EtcdMain
(
tests
func
()
int
)
{
setupETCD
()
os
.
Exit
(
tests
())
}
// return the EtcdURL
func
GetEtcdURL
()
string
{
return
etcdURL
}
test/integration/framework/master_utils.go
View file @
8e23c656
...
@@ -70,7 +70,6 @@ import (
...
@@ -70,7 +70,6 @@ import (
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl"
kubeletclient
"k8s.io/kubernetes/pkg/kubelet/client"
kubeletclient
"k8s.io/kubernetes/pkg/kubelet/client"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/util/env"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/plugin/pkg/admission/admit"
"k8s.io/kubernetes/plugin/pkg/admission/admit"
)
)
...
@@ -298,20 +297,13 @@ func parseCIDROrDie(cidr string) *net.IPNet {
...
@@ -298,20 +297,13 @@ func parseCIDROrDie(cidr string) *net.IPNet {
return
parsed
return
parsed
}
}
// return the EtcdURL
func
GetEtcdURLFromEnv
()
string
{
url
:=
env
.
GetEnvAsStringOrFallback
(
"KUBE_INTEGRATION_ETCD_URL"
,
"http://127.0.0.1:2379"
)
glog
.
V
(
4
)
.
Infof
(
"Using KUBE_INTEGRATION_ETCD_URL=%q"
,
url
)
return
url
}
// Returns a basic master config.
// Returns a basic master config.
func
NewMasterConfig
()
*
master
.
Config
{
func
NewMasterConfig
()
*
master
.
Config
{
// This causes the integration tests to exercise the etcd
// This causes the integration tests to exercise the etcd
// prefix code, so please don't change without ensuring
// prefix code, so please don't change without ensuring
// sufficient coverage in other ways.
// sufficient coverage in other ways.
etcdOptions
:=
options
.
NewEtcdOptions
(
storagebackend
.
NewDefaultConfig
(
uuid
.
New
(),
api
.
Scheme
,
nil
))
etcdOptions
:=
options
.
NewEtcdOptions
(
storagebackend
.
NewDefaultConfig
(
uuid
.
New
(),
api
.
Scheme
,
nil
))
etcdOptions
.
StorageConfig
.
ServerList
=
[]
string
{
GetEtcdURL
FromEnv
()}
etcdOptions
.
StorageConfig
.
ServerList
=
[]
string
{
GetEtcdURL
()}
info
,
_
:=
runtime
.
SerializerInfoForMediaType
(
api
.
Codecs
.
SupportedMediaTypes
(),
runtime
.
ContentTypeJSON
)
info
,
_
:=
runtime
.
SerializerInfoForMediaType
(
api
.
Codecs
.
SupportedMediaTypes
(),
runtime
.
ContentTypeJSON
)
ns
:=
NewSingleContentTypeSerializer
(
api
.
Scheme
,
info
)
ns
:=
NewSingleContentTypeSerializer
(
api
.
Scheme
,
info
)
...
...
third_party/etcd.BUILD
0 → 100644
View file @
8e23c656
exports_files(["etcd"])
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