mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #1104 from lavalamp/fix
Fix flaky scheduler factory test.
This commit is contained in:
commit
ab0d88667c
@ -34,7 +34,9 @@ type LogInterface interface {
|
|||||||
Logf(format string, args ...interface{})
|
Logf(format string, args ...interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// FakeHandler is to assist in testing HTTP requests.
|
// FakeHandler is to assist in testing HTTP requests. Notice that FakeHandler is
|
||||||
|
// not thread safe and you must not direct traffic to except for the request
|
||||||
|
// you want to test. You can do this by hiding it in an http.ServeMux.
|
||||||
type FakeHandler struct {
|
type FakeHandler struct {
|
||||||
RequestReceived *http.Request
|
RequestReceived *http.Request
|
||||||
RequestBody string
|
RequestBody string
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package factory
|
package factory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
@ -114,7 +115,10 @@ func TestPollMinions(t *testing.T) {
|
|||||||
ResponseBody: api.EncodeOrDie(ml),
|
ResponseBody: api.EncodeOrDie(ml),
|
||||||
T: t,
|
T: t,
|
||||||
}
|
}
|
||||||
server := httptest.NewServer(&handler)
|
mux := http.NewServeMux()
|
||||||
|
// FakeHandler musn't be sent requests other than the one you want to test.
|
||||||
|
mux.Handle("/api/v1beta1/minions", &handler)
|
||||||
|
server := httptest.NewServer(mux)
|
||||||
client := client.NewOrDie(server.URL, nil)
|
client := client.NewOrDie(server.URL, nil)
|
||||||
cf := ConfigFactory{client}
|
cf := ConfigFactory{client}
|
||||||
|
|
||||||
@ -138,7 +142,10 @@ func TestDefaultErrorFunc(t *testing.T) {
|
|||||||
ResponseBody: api.EncodeOrDie(testPod),
|
ResponseBody: api.EncodeOrDie(testPod),
|
||||||
T: t,
|
T: t,
|
||||||
}
|
}
|
||||||
server := httptest.NewServer(&handler)
|
mux := http.NewServeMux()
|
||||||
|
// FakeHandler musn't be sent requests other than the one you want to test.
|
||||||
|
mux.Handle("/api/v1beta1/pods/foo", &handler)
|
||||||
|
server := httptest.NewServer(mux)
|
||||||
factory := ConfigFactory{client.NewOrDie(server.URL, nil)}
|
factory := ConfigFactory{client.NewOrDie(server.URL, nil)}
|
||||||
queue := cache.NewFIFO()
|
queue := cache.NewFIFO()
|
||||||
errFunc := factory.makeDefaultErrorFunc(queue)
|
errFunc := factory.makeDefaultErrorFunc(queue)
|
||||||
|
Loading…
Reference in New Issue
Block a user