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
1972270f
Commit
1972270f
authored
Nov 12, 2016
by
Hongchao Deng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cacher test: fix leftover v2 test server
parent
454f60c7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
cacher_test.go
pkg/storage/cacher_test.go
+10
-9
utils.go
pkg/storage/etcd/testing/utils.go
+3
-3
No files found.
pkg/storage/cacher_test.go
View file @
1972270f
...
@@ -37,6 +37,7 @@ import (
...
@@ -37,6 +37,7 @@ import (
etcdstorage
"k8s.io/kubernetes/pkg/storage/etcd"
etcdstorage
"k8s.io/kubernetes/pkg/storage/etcd"
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest"
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest"
etcdtesting
"k8s.io/kubernetes/pkg/storage/etcd/testing"
etcdtesting
"k8s.io/kubernetes/pkg/storage/etcd/testing"
"k8s.io/kubernetes/pkg/storage/etcd3"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
...
@@ -45,15 +46,15 @@ import (
...
@@ -45,15 +46,15 @@ import (
)
)
func
newEtcdTestStorage
(
t
*
testing
.
T
,
codec
runtime
.
Codec
,
prefix
string
)
(
*
etcdtesting
.
EtcdTestServer
,
storage
.
Interface
)
{
func
newEtcdTestStorage
(
t
*
testing
.
T
,
codec
runtime
.
Codec
,
prefix
string
)
(
*
etcdtesting
.
EtcdTestServer
,
storage
.
Interface
)
{
server
:=
etcdtesting
.
NewEtcd
TestClientServer
(
t
)
server
,
_
:=
etcdtesting
.
NewUnsecuredEtcd3
TestClientServer
(
t
)
storage
:=
etcd
storage
.
NewEtcdStorage
(
server
.
Client
,
codec
,
prefix
,
false
,
etcdtest
.
DeserializationCacheSize
)
storage
:=
etcd
3
.
New
(
server
.
V3Client
,
codec
,
prefix
)
return
server
,
storage
return
server
,
storage
}
}
func
newTestCacher
(
s
storage
.
Interface
)
*
storage
.
Cacher
{
func
newTestCacher
(
s
storage
.
Interface
,
cap
int
)
*
storage
.
Cacher
{
prefix
:=
"pods"
prefix
:=
"pods"
config
:=
storage
.
CacherConfig
{
config
:=
storage
.
CacherConfig
{
CacheCapacity
:
10
,
CacheCapacity
:
cap
,
Storage
:
s
,
Storage
:
s
,
Versioner
:
etcdstorage
.
APIObjectVersioner
{},
Versioner
:
etcdstorage
.
APIObjectVersioner
{},
Type
:
&
api
.
Pod
{},
Type
:
&
api
.
Pod
{},
...
@@ -96,7 +97,7 @@ func updatePod(t *testing.T, s storage.Interface, obj, old *api.Pod) *api.Pod {
...
@@ -96,7 +97,7 @@ func updatePod(t *testing.T, s storage.Interface, obj, old *api.Pod) *api.Pod {
func
TestList
(
t
*
testing
.
T
)
{
func
TestList
(
t
*
testing
.
T
)
{
server
,
etcdStorage
:=
newEtcdTestStorage
(
t
,
testapi
.
Default
.
Codec
(),
etcdtest
.
PathPrefix
())
server
,
etcdStorage
:=
newEtcdTestStorage
(
t
,
testapi
.
Default
.
Codec
(),
etcdtest
.
PathPrefix
())
defer
server
.
Terminate
(
t
)
defer
server
.
Terminate
(
t
)
cacher
:=
newTestCacher
(
etcdStorage
)
cacher
:=
newTestCacher
(
etcdStorage
,
10
)
defer
cacher
.
Stop
()
defer
cacher
.
Stop
()
podFoo
:=
makeTestPod
(
"foo"
)
podFoo
:=
makeTestPod
(
"foo"
)
...
@@ -210,7 +211,7 @@ func TestWatch(t *testing.T) {
...
@@ -210,7 +211,7 @@ func TestWatch(t *testing.T) {
// Inject one list error to make sure we test the relist case.
// Inject one list error to make sure we test the relist case.
etcdStorage
=
&
injectListError
{
errors
:
1
,
Interface
:
etcdStorage
}
etcdStorage
=
&
injectListError
{
errors
:
1
,
Interface
:
etcdStorage
}
defer
server
.
Terminate
(
t
)
defer
server
.
Terminate
(
t
)
cacher
:=
newTestCacher
(
etcdStorage
)
cacher
:=
newTestCacher
(
etcdStorage
,
3
)
// small capacity to trigger "too old version" error
defer
cacher
.
Stop
()
defer
cacher
.
Stop
()
podFoo
:=
makeTestPod
(
"foo"
)
podFoo
:=
makeTestPod
(
"foo"
)
...
@@ -285,7 +286,7 @@ func TestWatch(t *testing.T) {
...
@@ -285,7 +286,7 @@ func TestWatch(t *testing.T) {
func
TestWatcherTimeout
(
t
*
testing
.
T
)
{
func
TestWatcherTimeout
(
t
*
testing
.
T
)
{
server
,
etcdStorage
:=
newEtcdTestStorage
(
t
,
testapi
.
Default
.
Codec
(),
etcdtest
.
PathPrefix
())
server
,
etcdStorage
:=
newEtcdTestStorage
(
t
,
testapi
.
Default
.
Codec
(),
etcdtest
.
PathPrefix
())
defer
server
.
Terminate
(
t
)
defer
server
.
Terminate
(
t
)
cacher
:=
newTestCacher
(
etcdStorage
)
cacher
:=
newTestCacher
(
etcdStorage
,
10
)
defer
cacher
.
Stop
()
defer
cacher
.
Stop
()
// initialVersion is used to initate the watcher at the beginning of the world,
// initialVersion is used to initate the watcher at the beginning of the world,
...
@@ -320,7 +321,7 @@ func TestWatcherTimeout(t *testing.T) {
...
@@ -320,7 +321,7 @@ func TestWatcherTimeout(t *testing.T) {
func
TestFiltering
(
t
*
testing
.
T
)
{
func
TestFiltering
(
t
*
testing
.
T
)
{
server
,
etcdStorage
:=
newEtcdTestStorage
(
t
,
testapi
.
Default
.
Codec
(),
etcdtest
.
PathPrefix
())
server
,
etcdStorage
:=
newEtcdTestStorage
(
t
,
testapi
.
Default
.
Codec
(),
etcdtest
.
PathPrefix
())
defer
server
.
Terminate
(
t
)
defer
server
.
Terminate
(
t
)
cacher
:=
newTestCacher
(
etcdStorage
)
cacher
:=
newTestCacher
(
etcdStorage
,
10
)
defer
cacher
.
Stop
()
defer
cacher
.
Stop
()
// Ensure that the cacher is initialized, before creating any pods,
// Ensure that the cacher is initialized, before creating any pods,
...
@@ -382,7 +383,7 @@ func TestFiltering(t *testing.T) {
...
@@ -382,7 +383,7 @@ func TestFiltering(t *testing.T) {
func
TestStartingResourceVersion
(
t
*
testing
.
T
)
{
func
TestStartingResourceVersion
(
t
*
testing
.
T
)
{
server
,
etcdStorage
:=
newEtcdTestStorage
(
t
,
testapi
.
Default
.
Codec
(),
etcdtest
.
PathPrefix
())
server
,
etcdStorage
:=
newEtcdTestStorage
(
t
,
testapi
.
Default
.
Codec
(),
etcdtest
.
PathPrefix
())
defer
server
.
Terminate
(
t
)
defer
server
.
Terminate
(
t
)
cacher
:=
newTestCacher
(
etcdStorage
)
cacher
:=
newTestCacher
(
etcdStorage
,
10
)
defer
cacher
.
Stop
()
defer
cacher
.
Stop
()
// add 1 object
// add 1 object
...
...
pkg/storage/etcd/testing/utils.go
View file @
1972270f
...
@@ -63,7 +63,7 @@ type EtcdTestServer struct {
...
@@ -63,7 +63,7 @@ type EtcdTestServer struct {
// The following are lumped etcd3 test server params
// The following are lumped etcd3 test server params
v3Cluster
*
integration
.
ClusterV3
v3Cluster
*
integration
.
ClusterV3
v
3Client
*
clientv3
.
Client
V
3Client
*
clientv3
.
Client
}
}
// newLocalListener opens a port localhost using any port
// newLocalListener opens a port localhost using any port
...
@@ -314,11 +314,11 @@ func NewUnsecuredEtcd3TestClientServer(t *testing.T) (*EtcdTestServer, *storageb
...
@@ -314,11 +314,11 @@ func NewUnsecuredEtcd3TestClientServer(t *testing.T) (*EtcdTestServer, *storageb
server
:=
&
EtcdTestServer
{
server
:=
&
EtcdTestServer
{
v3Cluster
:
integration
.
NewClusterV3
(
t
,
&
integration
.
ClusterConfig
{
Size
:
1
}),
v3Cluster
:
integration
.
NewClusterV3
(
t
,
&
integration
.
ClusterConfig
{
Size
:
1
}),
}
}
server
.
v
3Client
=
server
.
v3Cluster
.
RandClient
()
server
.
V
3Client
=
server
.
v3Cluster
.
RandClient
()
config
:=
&
storagebackend
.
Config
{
config
:=
&
storagebackend
.
Config
{
Type
:
"etcd3"
,
Type
:
"etcd3"
,
Prefix
:
etcdtest
.
PathPrefix
(),
Prefix
:
etcdtest
.
PathPrefix
(),
ServerList
:
server
.
v
3Client
.
Endpoints
(),
ServerList
:
server
.
V
3Client
.
Endpoints
(),
DeserializationCacheSize
:
etcdtest
.
DeserializationCacheSize
,
DeserializationCacheSize
:
etcdtest
.
DeserializationCacheSize
,
}
}
return
server
,
config
return
server
,
config
...
...
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