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
44f2c8f0
Commit
44f2c8f0
authored
Jun 04, 2015
by
Quinton Hoole
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9263 from caesarxuchao/add-v1-tests-fix
Fix some v1 tests issues
parents
b5251de1
080da97e
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
123 deletions
+23
-123
latest_test.go
pkg/api/latest/latest_test.go
+0
-3
testapi_test.go
pkg/api/testapi/testapi_test.go
+16
-105
helpers_test.go
pkg/kubectl/cmd/util/helpers_test.go
+2
-2
master.go
pkg/master/master.go
+1
-8
etcd_test.go
pkg/registry/podtemplate/etcd/etcd_test.go
+2
-2
helper_test.go
pkg/runtime/helper_test.go
+2
-3
No files found.
pkg/api/latest/latest_test.go
View file @
44f2c8f0
...
@@ -70,9 +70,6 @@ func TestInterfacesFor(t *testing.T) {
...
@@ -70,9 +70,6 @@ func TestInterfacesFor(t *testing.T) {
}
}
func
TestRESTMapper
(
t
*
testing
.
T
)
{
func
TestRESTMapper
(
t
*
testing
.
T
)
{
if
v
,
k
,
err
:=
RESTMapper
.
VersionAndKindForResource
(
"replicationControllers"
);
err
!=
nil
||
v
!=
"v1beta3"
||
k
!=
"ReplicationController"
{
t
.
Errorf
(
"unexpected version mapping: %s %s %v"
,
v
,
k
,
err
)
}
if
v
,
k
,
err
:=
RESTMapper
.
VersionAndKindForResource
(
"replicationcontrollers"
);
err
!=
nil
||
v
!=
"v1beta3"
||
k
!=
"ReplicationController"
{
if
v
,
k
,
err
:=
RESTMapper
.
VersionAndKindForResource
(
"replicationcontrollers"
);
err
!=
nil
||
v
!=
"v1beta3"
||
k
!=
"ReplicationController"
{
t
.
Errorf
(
"unexpected version mapping: %s %s %v"
,
v
,
k
,
err
)
t
.
Errorf
(
"unexpected version mapping: %s %s %v"
,
v
,
k
,
err
)
}
}
...
...
pkg/api/testapi/testapi_test.go
View file @
44f2c8f0
...
@@ -20,38 +20,7 @@ import (
...
@@ -20,38 +20,7 @@ import (
"testing"
"testing"
)
)
func
TestResourcePathWithPrefixForV1Beta3
(
t
*
testing
.
T
)
{
func
TestResourcePathWithPrefix
(
t
*
testing
.
T
)
{
if
Version
()
!=
"v1beta3"
{
// Skip the test if we are not testing v1beta3.
return
}
testCases
:=
[]
struct
{
prefix
string
resource
string
namespace
string
name
string
expected
string
}{
{
"prefix"
,
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/v1beta3/prefix/namespaces/mynamespace/resource/myresource"
},
{
"prefix"
,
"resource"
,
""
,
"myresource"
,
"/api/v1beta3/prefix/resource/myresource"
},
{
"prefix"
,
"resource"
,
"mynamespace"
,
""
,
"/api/v1beta3/prefix/namespaces/mynamespace/resource"
},
{
"prefix"
,
"resource"
,
""
,
""
,
"/api/v1beta3/prefix/resource"
},
{
""
,
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/v1beta3/namespaces/mynamespace/resource/myresource"
},
}
for
_
,
item
:=
range
testCases
{
if
actual
:=
ResourcePathWithPrefix
(
item
.
prefix
,
item
.
resource
,
item
.
namespace
,
item
.
name
);
actual
!=
item
.
expected
{
t
.
Errorf
(
"Expected: %s, got: %s for prefix: %s, resource: %s, namespace: %s and name: %s"
,
item
.
expected
,
actual
,
item
.
prefix
,
item
.
resource
,
item
.
namespace
,
item
.
name
)
}
}
}
func
TestResourcePathWithPrefixForV1
(
t
*
testing
.
T
)
{
if
Version
()
!=
"v1"
{
// Skip the test if we are not testing v1.
return
}
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
prefix
string
prefix
string
resource
string
resource
string
...
@@ -59,11 +28,11 @@ func TestResourcePathWithPrefixForV1(t *testing.T) {
...
@@ -59,11 +28,11 @@ func TestResourcePathWithPrefixForV1(t *testing.T) {
name
string
name
string
expected
string
expected
string
}{
}{
{
"prefix"
,
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/
v1
/prefix/namespaces/mynamespace/resource/myresource"
},
{
"prefix"
,
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/
"
+
Version
()
+
"
/prefix/namespaces/mynamespace/resource/myresource"
},
{
"prefix"
,
"resource"
,
""
,
"myresource"
,
"/api/
v1
/prefix/resource/myresource"
},
{
"prefix"
,
"resource"
,
""
,
"myresource"
,
"/api/
"
+
Version
()
+
"
/prefix/resource/myresource"
},
{
"prefix"
,
"resource"
,
"mynamespace"
,
""
,
"/api/
v1
/prefix/namespaces/mynamespace/resource"
},
{
"prefix"
,
"resource"
,
"mynamespace"
,
""
,
"/api/
"
+
Version
()
+
"
/prefix/namespaces/mynamespace/resource"
},
{
"prefix"
,
"resource"
,
""
,
""
,
"/api/
v1
/prefix/resource"
},
{
"prefix"
,
"resource"
,
""
,
""
,
"/api/
"
+
Version
()
+
"
/prefix/resource"
},
{
""
,
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/
v1
/namespaces/mynamespace/resource/myresource"
},
{
""
,
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/
"
+
Version
()
+
"
/namespaces/mynamespace/resource/myresource"
},
}
}
for
_
,
item
:=
range
testCases
{
for
_
,
item
:=
range
testCases
{
if
actual
:=
ResourcePathWithPrefix
(
item
.
prefix
,
item
.
resource
,
item
.
namespace
,
item
.
name
);
actual
!=
item
.
expected
{
if
actual
:=
ResourcePathWithPrefix
(
item
.
prefix
,
item
.
resource
,
item
.
namespace
,
item
.
name
);
actual
!=
item
.
expected
{
...
@@ -72,22 +41,17 @@ func TestResourcePathWithPrefixForV1(t *testing.T) {
...
@@ -72,22 +41,17 @@ func TestResourcePathWithPrefixForV1(t *testing.T) {
}
}
}
}
func
TestResourcePathForV1Beta3
(
t
*
testing
.
T
)
{
func
TestResourcePath
(
t
*
testing
.
T
)
{
if
Version
()
!=
"v1beta3"
{
// Skip the test if we are not testing v1beta3.
return
}
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
resource
string
resource
string
namespace
string
namespace
string
name
string
name
string
expected
string
expected
string
}{
}{
{
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/
v1beta3
/namespaces/mynamespace/resource/myresource"
},
{
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/
"
+
Version
()
+
"
/namespaces/mynamespace/resource/myresource"
},
{
"resource"
,
""
,
"myresource"
,
"/api/
v1beta3
/resource/myresource"
},
{
"resource"
,
""
,
"myresource"
,
"/api/
"
+
Version
()
+
"
/resource/myresource"
},
{
"resource"
,
"mynamespace"
,
""
,
"/api/
v1beta3
/namespaces/mynamespace/resource"
},
{
"resource"
,
"mynamespace"
,
""
,
"/api/
"
+
Version
()
+
"
/namespaces/mynamespace/resource"
},
{
"resource"
,
""
,
""
,
"/api/
v1beta3
/resource"
},
{
"resource"
,
""
,
""
,
"/api/
"
+
Version
()
+
"
/resource"
},
}
}
for
_
,
item
:=
range
testCases
{
for
_
,
item
:=
range
testCases
{
if
actual
:=
ResourcePath
(
item
.
resource
,
item
.
namespace
,
item
.
name
);
actual
!=
item
.
expected
{
if
actual
:=
ResourcePath
(
item
.
resource
,
item
.
namespace
,
item
.
name
);
actual
!=
item
.
expected
{
...
@@ -96,70 +60,17 @@ func TestResourcePathForV1Beta3(t *testing.T) {
...
@@ -96,70 +60,17 @@ func TestResourcePathForV1Beta3(t *testing.T) {
}
}
}
}
func
TestResourcePathForV1
(
t
*
testing
.
T
)
{
func
TestResourcePathWithNamespaceQuery
(
t
*
testing
.
T
)
{
if
Version
()
!=
"v1"
{
// Skip the test if we are not testing v1.
return
}
testCases
:=
[]
struct
{
resource
string
namespace
string
name
string
expected
string
}{
{
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/v1/namespaces/mynamespace/resource/myresource"
},
{
"resource"
,
""
,
"myresource"
,
"/api/v1/resource/myresource"
},
{
"resource"
,
"mynamespace"
,
""
,
"/api/v1/namespaces/mynamespace/resource"
},
{
"resource"
,
""
,
""
,
"/api/v1/resource"
},
}
for
_
,
item
:=
range
testCases
{
if
actual
:=
ResourcePath
(
item
.
resource
,
item
.
namespace
,
item
.
name
);
actual
!=
item
.
expected
{
t
.
Errorf
(
"Expected: %s, got: %s for resource: %s, namespace: %s and name: %s"
,
item
.
expected
,
actual
,
item
.
resource
,
item
.
namespace
,
item
.
name
)
}
}
}
func
TestResourcePathWithNamespaceQueryForV1Beta3
(
t
*
testing
.
T
)
{
if
Version
()
!=
"v1beta3"
{
// Skip the test if we are not testing v1beta3.
return
}
testCases
:=
[]
struct
{
resource
string
namespace
string
name
string
expected
string
}{
{
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/v1beta3/namespaces/mynamespace/resource/myresource"
},
{
"resource"
,
""
,
"myresource"
,
"/api/v1beta3/resource/myresource"
},
{
"resource"
,
"mynamespace"
,
""
,
"/api/v1beta3/namespaces/mynamespace/resource"
},
{
"resource"
,
""
,
""
,
"/api/v1beta3/resource"
},
}
for
_
,
item
:=
range
testCases
{
if
actual
:=
ResourcePathWithNamespaceQuery
(
item
.
resource
,
item
.
namespace
,
item
.
name
);
actual
!=
item
.
expected
{
t
.
Errorf
(
"Expected: %s, got: %s for resource: %s, namespace: %s and name: %s"
,
item
.
expected
,
actual
,
item
.
resource
,
item
.
namespace
,
item
.
name
)
}
}
}
func
TestResourcePathWithNamespaceQueryForV1
(
t
*
testing
.
T
)
{
if
Version
()
!=
"v1"
{
// Skip the test if we are not testing v1.
return
}
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
resource
string
resource
string
namespace
string
namespace
string
name
string
name
string
expected
string
expected
string
}{
}{
{
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/
v1
/namespaces/mynamespace/resource/myresource"
},
{
"resource"
,
"mynamespace"
,
"myresource"
,
"/api/
"
+
Version
()
+
"
/namespaces/mynamespace/resource/myresource"
},
{
"resource"
,
""
,
"myresource"
,
"/api/
v1
/resource/myresource"
},
{
"resource"
,
""
,
"myresource"
,
"/api/
"
+
Version
()
+
"
/resource/myresource"
},
{
"resource"
,
"mynamespace"
,
""
,
"/api/
v1
/namespaces/mynamespace/resource"
},
{
"resource"
,
"mynamespace"
,
""
,
"/api/
"
+
Version
()
+
"
/namespaces/mynamespace/resource"
},
{
"resource"
,
""
,
""
,
"/api/
v1
/resource"
},
{
"resource"
,
""
,
""
,
"/api/
"
+
Version
()
+
"
/resource"
},
}
}
for
_
,
item
:=
range
testCases
{
for
_
,
item
:=
range
testCases
{
if
actual
:=
ResourcePathWithNamespaceQuery
(
item
.
resource
,
item
.
namespace
,
item
.
name
);
actual
!=
item
.
expected
{
if
actual
:=
ResourcePathWithNamespaceQuery
(
item
.
resource
,
item
.
namespace
,
item
.
name
);
actual
!=
item
.
expected
{
...
...
pkg/kubectl/cmd/util/helpers_test.go
View file @
44f2c8f0
...
@@ -55,7 +55,7 @@ func TestMerge(t *testing.T) {
...
@@ -55,7 +55,7 @@ func TestMerge(t *testing.T) {
},
},
},
},
/* TODO: uncomment this test once Merge is updated to use
/* TODO: uncomment this test once Merge is updated to use
strategic-merge-patch. See #844.
strategic-merge-patch. See #844
9
.
{
{
kind: "Pod",
kind: "Pod",
obj: &api.Pod{
obj: &api.Pod{
...
@@ -193,7 +193,7 @@ func TestMerge(t *testing.T) {
...
@@ -193,7 +193,7 @@ func TestMerge(t *testing.T) {
},
},
},
},
/* TODO: uncomment this test once Merge is updated to use
/* TODO: uncomment this test once Merge is updated to use
strategic-merge-patch. See #844.
strategic-merge-patch. See #844
9
.
{
{
kind: "Pod",
kind: "Pod",
obj: &api.Pod{
obj: &api.Pod{
...
...
pkg/master/master.go
View file @
44f2c8f0
...
@@ -389,17 +389,10 @@ func logStackOnRecover(panicReason interface{}, httpWriter http.ResponseWriter)
...
@@ -389,17 +389,10 @@ func logStackOnRecover(panicReason interface{}, httpWriter http.ResponseWriter)
// init initializes master.
// init initializes master.
func
(
m
*
Master
)
init
(
c
*
Config
)
{
func
(
m
*
Master
)
init
(
c
*
Config
)
{
// TODO: make initialization of the helper part of the Master, and allow some storage
// objects to have a newer storage version than the user's default.
newerHelper
,
err
:=
NewEtcdHelper
(
c
.
EtcdHelper
.
Client
,
"v1beta3"
,
DefaultEtcdPathPrefix
)
if
err
!=
nil
{
glog
.
Fatalf
(
"Unable to setup storage for v1beta3: %v"
,
err
)
}
podStorage
:=
podetcd
.
NewStorage
(
c
.
EtcdHelper
,
c
.
KubeletClient
)
podStorage
:=
podetcd
.
NewStorage
(
c
.
EtcdHelper
,
c
.
KubeletClient
)
podRegistry
:=
pod
.
NewRegistry
(
podStorage
.
Pod
)
podRegistry
:=
pod
.
NewRegistry
(
podStorage
.
Pod
)
podTemplateStorage
:=
podtemplateetcd
.
NewREST
(
newer
Helper
)
podTemplateStorage
:=
podtemplateetcd
.
NewREST
(
c
.
Etcd
Helper
)
eventRegistry
:=
event
.
NewEtcdRegistry
(
c
.
EtcdHelper
,
uint64
(
c
.
EventTTL
.
Seconds
()))
eventRegistry
:=
event
.
NewEtcdRegistry
(
c
.
EtcdHelper
,
uint64
(
c
.
EventTTL
.
Seconds
()))
limitRangeRegistry
:=
limitrange
.
NewEtcdRegistry
(
c
.
EtcdHelper
)
limitRangeRegistry
:=
limitrange
.
NewEtcdRegistry
(
c
.
EtcdHelper
)
...
...
pkg/registry/podtemplate/etcd/etcd_test.go
View file @
44f2c8f0
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest/resttest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest/resttest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/
v1beta3
"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/
testapi
"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
)
)
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
func
newHelper
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
tools
.
EtcdHelper
)
{
func
newHelper
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
tools
.
EtcdHelper
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
fakeEtcdClient
.
TestIndex
=
true
helper
:=
tools
.
NewEtcdHelper
(
fakeEtcdClient
,
v1beta3
.
Codec
,
etcdtest
.
PathPrefix
())
helper
:=
tools
.
NewEtcdHelper
(
fakeEtcdClient
,
testapi
.
Codec
()
,
etcdtest
.
PathPrefix
())
return
fakeEtcdClient
,
helper
return
fakeEtcdClient
,
helper
}
}
...
...
pkg/runtime/helper_test.go
View file @
44f2c8f0
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"testing"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
_
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3
"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi
"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
...
@@ -137,8 +137,7 @@ func TestDecodeList(t *testing.T) {
...
@@ -137,8 +137,7 @@ func TestDecodeList(t *testing.T) {
pl
:=
&
api
.
List
{
pl
:=
&
api
.
List
{
Items
:
[]
runtime
.
Object
{
Items
:
[]
runtime
.
Object
{
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"1"
}},
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"1"
}},
&
runtime
.
Unknown
{
TypeMeta
:
runtime
.
TypeMeta
{
Kind
:
"Pod"
,
APIVersion
:
"v1beta3"
},
RawJSON
:
[]
byte
(
`{"kind":"Pod","apiVersion":"v1beta3","metadata":{"name":"test"}}`
)},
&
runtime
.
Unknown
{
TypeMeta
:
runtime
.
TypeMeta
{
Kind
:
"Pod"
,
APIVersion
:
testapi
.
Version
()},
RawJSON
:
[]
byte
(
`{"kind":"Pod","apiVersion":"`
+
testapi
.
Version
()
+
`","metadata":{"name":"test"}}`
)},
&
runtime
.
Unknown
{
TypeMeta
:
runtime
.
TypeMeta
{
Kind
:
"Pod"
,
APIVersion
:
"v1"
},
RawJSON
:
[]
byte
(
`{"kind":"Pod","apiVersion":"v1","metadata":{"name":"test"}}`
)},
&
runtime
.
Unstructured
{
TypeMeta
:
runtime
.
TypeMeta
{
Kind
:
"Foo"
,
APIVersion
:
"Bar"
},
Object
:
map
[
string
]
interface
{}{
"test"
:
"value"
}},
&
runtime
.
Unstructured
{
TypeMeta
:
runtime
.
TypeMeta
{
Kind
:
"Foo"
,
APIVersion
:
"Bar"
},
Object
:
map
[
string
]
interface
{}{
"test"
:
"value"
}},
},
},
}
}
...
...
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