mirror of https://github.com/k3s-io/k3s
move pkg/scheduler/util/testutil.go to pkg/scheduler/testing
parent
ae53b78971
commit
56b3f2f409
|
@ -284,13 +284,13 @@ func TestDefaultErrorFunc(t *testing.T) {
|
||||||
}
|
}
|
||||||
handler := utiltesting.FakeHandler{
|
handler := utiltesting.FakeHandler{
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
ResponseBody: runtime.EncodeOrDie(util.Test.Codec(), testPod),
|
ResponseBody: runtime.EncodeOrDie(schedulertesting.Test.Codec(), testPod),
|
||||||
T: t,
|
T: t,
|
||||||
}
|
}
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
// FakeHandler mustn't be sent requests other than the one you want to test.
|
// FakeHandler mustn't be sent requests other than the one you want to test.
|
||||||
mux.Handle(util.Test.ResourcePath(string(v1.ResourcePods), "bar", "foo"), &handler)
|
mux.Handle(schedulertesting.Test.ResourcePath(string(v1.ResourcePods), "bar", "foo"), &handler)
|
||||||
server := httptest.NewServer(mux)
|
server := httptest.NewServer(mux)
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersions[0]}})
|
client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &legacyscheme.Registry.GroupOrDie(v1.GroupName).GroupVersions[0]}})
|
||||||
|
@ -309,7 +309,7 @@ func TestDefaultErrorFunc(t *testing.T) {
|
||||||
if !exists {
|
if !exists {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
handler.ValidateRequest(t, util.Test.ResourcePath(string(v1.ResourcePods), "bar", "foo"), "GET", nil)
|
handler.ValidateRequest(t, schedulertesting.Test.ResourcePath(string(v1.ResourcePods), "bar", "foo"), "GET", nil)
|
||||||
if e, a := testPod, got; !reflect.DeepEqual(e, a) {
|
if e, a := testPod, got; !reflect.DeepEqual(e, a) {
|
||||||
t.Errorf("Expected %v, got %v", e, a)
|
t.Errorf("Expected %v, got %v", e, a)
|
||||||
}
|
}
|
||||||
|
@ -371,9 +371,9 @@ func TestBind(t *testing.T) {
|
||||||
t.Errorf("Unexpected error: %v", err)
|
t.Errorf("Unexpected error: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
expectedBody := runtime.EncodeOrDie(util.Test.Codec(), item.binding)
|
expectedBody := runtime.EncodeOrDie(schedulertesting.Test.Codec(), item.binding)
|
||||||
handler.ValidateRequest(t,
|
handler.ValidateRequest(t,
|
||||||
util.Test.SubResourcePath(string(v1.ResourcePods), metav1.NamespaceDefault, "foo", "binding"),
|
schedulertesting.Test.SubResourcePath(string(v1.ResourcePods), metav1.NamespaceDefault, "foo", "binding"),
|
||||||
"POST", &expectedBody)
|
"POST", &expectedBody)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/scheduler/core"
|
"k8s.io/kubernetes/pkg/scheduler/core"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/schedulercache"
|
"k8s.io/kubernetes/pkg/scheduler/schedulercache"
|
||||||
schedulertesting "k8s.io/kubernetes/pkg/scheduler/testing"
|
schedulertesting "k8s.io/kubernetes/pkg/scheduler/testing"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/util"
|
|
||||||
"k8s.io/kubernetes/pkg/scheduler/volumebinder"
|
"k8s.io/kubernetes/pkg/scheduler/volumebinder"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -79,7 +78,7 @@ func podWithID(id, desiredHost string) *v1.Pod {
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: id,
|
Name: id,
|
||||||
UID: types.UID(id),
|
UID: types.UID(id),
|
||||||
SelfLink: util.Test.SelfLink(string(v1.ResourcePods), id),
|
SelfLink: schedulertesting.Test.SelfLink(string(v1.ResourcePods), id),
|
||||||
},
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
NodeName: desiredHost,
|
NodeName: desiredHost,
|
||||||
|
@ -93,7 +92,7 @@ func deletingPod(id string) *v1.Pod {
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: id,
|
Name: id,
|
||||||
UID: types.UID(id),
|
UID: types.UID(id),
|
||||||
SelfLink: util.Test.SelfLink(string(v1.ResourcePods), id),
|
SelfLink: schedulertesting.Test.SelfLink(string(v1.ResourcePods), id),
|
||||||
DeletionTimestamp: &deletionTimestamp,
|
DeletionTimestamp: &deletionTimestamp,
|
||||||
},
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package util
|
package testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package util
|
package testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
Loading…
Reference in New Issue