@@ -23,6 +23,7 @@ import (
23
23
"io/ioutil"
24
24
"net/http"
25
25
"net/http/httptest"
26
+ "path"
26
27
"reflect"
27
28
"testing"
28
29
@@ -39,17 +40,20 @@ import (
39
40
restclient "k8s.io/client-go/rest"
40
41
"k8s.io/client-go/tools/pager"
41
42
"k8s.io/klog"
42
- "k8s.io/kubernetes/pkg/api/testapi"
43
- api "k8s.io/kubernetes/pkg/apis/core"
44
43
"k8s.io/kubernetes/pkg/master"
45
44
"k8s.io/kubernetes/test/integration/framework"
46
45
)
47
46
48
47
func setup (t * testing.T , groupVersions ... schema.GroupVersion ) (* httptest.Server , clientset.Interface , framework.CloseFunc ) {
48
+ return setupWithResources (t , groupVersions , nil )
49
+ }
50
+
51
+ func setupWithResources (t * testing.T , groupVersions []schema.GroupVersion , resources []schema.GroupVersionResource ) (* httptest.Server , clientset.Interface , framework.CloseFunc ) {
49
52
masterConfig := framework .NewIntegrationTestMasterConfig ()
50
- if len (groupVersions ) > 0 {
53
+ if len (groupVersions ) > 0 || len ( resources ) > 0 {
51
54
resourceConfig := master .DefaultAPIResourceConfigSource ()
52
55
resourceConfig .EnableVersions (groupVersions ... )
56
+ resourceConfig .EnableResources (resources ... )
53
57
masterConfig .ExtraConfig .APIResourceConfigSource = resourceConfig
54
58
}
55
59
_ , s , closeFn := framework .RunAMaster (masterConfig )
@@ -82,10 +86,6 @@ func verifyStatusCode(t *testing.T, verb, URL, body string, expectedStatusCode i
82
86
}
83
87
}
84
88
85
- func path (resource , namespace , name string ) string {
86
- return testapi .Extensions .ResourcePath (resource , namespace , name )
87
- }
88
-
89
89
func newRS (namespace string ) * apps.ReplicaSet {
90
90
return & apps.ReplicaSet {
91
91
TypeMeta : metav1.TypeMeta {
@@ -118,7 +118,7 @@ func newRS(namespace string) *apps.ReplicaSet {
118
118
var cascDel = `
119
119
{
120
120
"kind": "DeleteOptions",
121
- "apiVersion": "` + testapi . Groups [ api . GroupName ]. GroupVersion (). String () + ` ",
121
+ "apiVersion": "v1 ",
122
122
"orphanDependents": false
123
123
}
124
124
`
@@ -139,7 +139,7 @@ func Test202StatusCode(t *testing.T) {
139
139
if err != nil {
140
140
t .Fatalf ("Failed to create rs: %v" , err )
141
141
}
142
- verifyStatusCode (t , "DELETE" , s .URL + path ( "replicasets " , ns .Name , rs .Name ), "" , 200 )
142
+ verifyStatusCode (t , "DELETE" , s .URL + path . Join ( "/apis/apps/v1/namespaces " , ns .Name , "replicasets" , rs .Name ), "" , 200 )
143
143
144
144
// 2. Create the resource with a finalizer so that the resource is not immediately deleted and then delete it without setting DeleteOptions.
145
145
// Verify that the apiserver still returns 200 since DeleteOptions.OrphanDependents is not set.
@@ -149,7 +149,7 @@ func Test202StatusCode(t *testing.T) {
149
149
if err != nil {
150
150
t .Fatalf ("Failed to create rs: %v" , err )
151
151
}
152
- verifyStatusCode (t , "DELETE" , s .URL + path ( "replicasets " , ns .Name , rs .Name ), "" , 200 )
152
+ verifyStatusCode (t , "DELETE" , s .URL + path . Join ( "/apis/apps/v1/namespaces " , ns .Name , "replicasets" , rs .Name ), "" , 200 )
153
153
154
154
// 3. Create the resource and then delete it with DeleteOptions.OrphanDependents=false.
155
155
// Verify that the server still returns 200 since the resource is immediately deleted.
@@ -158,7 +158,7 @@ func Test202StatusCode(t *testing.T) {
158
158
if err != nil {
159
159
t .Fatalf ("Failed to create rs: %v" , err )
160
160
}
161
- verifyStatusCode (t , "DELETE" , s .URL + path ( "replicasets " , ns .Name , rs .Name ), cascDel , 200 )
161
+ verifyStatusCode (t , "DELETE" , s .URL + path . Join ( "/apis/apps/v1/namespaces " , ns .Name , "replicasets" , rs .Name ), cascDel , 200 )
162
162
163
163
// 4. Create the resource with a finalizer so that the resource is not immediately deleted and then delete it with DeleteOptions.OrphanDependents=false.
164
164
// Verify that the server returns 202 in this case.
@@ -168,7 +168,7 @@ func Test202StatusCode(t *testing.T) {
168
168
if err != nil {
169
169
t .Fatalf ("Failed to create rs: %v" , err )
170
170
}
171
- verifyStatusCode (t , "DELETE" , s .URL + path ( "replicasets " , ns .Name , rs .Name ), cascDel , 202 )
171
+ verifyStatusCode (t , "DELETE" , s .URL + path . Join ( "/apis/apps/v1/namespaces " , ns .Name , "replicasets" , rs .Name ), cascDel , 202 )
172
172
}
173
173
174
174
func TestAPIListChunking (t * testing.T ) {
0 commit comments