mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
fix wrong assertion on tests
Signed-off-by: xin.li <xin.li@daocloud.io>
This commit is contained in:
parent
0a08529144
commit
bc4ae15d77
@ -29,8 +29,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@ -124,7 +122,9 @@ func fakeServer(t *testing.T, requestReceived chan struct{}, testName string, ex
|
||||
}
|
||||
|
||||
opts, err := remotecommand.NewOptions(req)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
if exec {
|
||||
cmd := req.URL.Query()[api.ExecCommandParam]
|
||||
remotecommand.ServeExec(w, req, executor, "pod", "uid", "container", cmd, opts, 0, 10*time.Second, serverProtocols)
|
||||
|
@ -172,7 +172,9 @@ func TestRotateLogs(t *testing.T) {
|
||||
err = wait.PollUntilContextCancel(pollTimeoutCtx, 5*time.Millisecond, false, func(ctx context.Context) (done bool, err error) {
|
||||
return c.queue.Len() == 0, nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
c.queue.ShutDown()
|
||||
}()
|
||||
// This is a blocking call. But the above routine takes care of ensuring that this is terminated once the queue is shutdown
|
||||
|
@ -200,9 +200,13 @@ func TestWithAuditConcurrency(t *testing.T) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
mutator, ok := handler.(MutationInterface)
|
||||
require.True(t, ok)
|
||||
if !ok {
|
||||
t.Error("handler is not an interface of type MutationInterface")
|
||||
}
|
||||
auditMutator, ok := auditHandler.(MutationInterface)
|
||||
require.True(t, ok)
|
||||
if !ok {
|
||||
t.Error("handler is not an interface of type MutationInterface")
|
||||
}
|
||||
assert.Equal(t, mutator.Admit(ctx, a, nil), auditMutator.Admit(ctx, a, nil), "WithAudit decorator should not effect the return value")
|
||||
}()
|
||||
}
|
||||
|
@ -199,7 +199,9 @@ func TestReconcile(t *testing.T) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
stopReason := myController.Run(testContext)
|
||||
require.ErrorIs(t, stopReason, context.Canceled)
|
||||
if !errors.Is(stopReason, context.Canceled) {
|
||||
t.Errorf("expected error to be context.Canceled, but got: %v", stopReason)
|
||||
}
|
||||
}()
|
||||
|
||||
// The controller is blocked because the reconcile function sends on an
|
||||
@ -255,7 +257,9 @@ func TestShutdown(t *testing.T) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
stopReason := myController.Run(testContext)
|
||||
require.ErrorIs(t, stopReason, context.Canceled)
|
||||
if !errors.Is(stopReason, context.Canceled) {
|
||||
t.Errorf("expected error to be context.Canceled, but got: %v", stopReason)
|
||||
}
|
||||
}()
|
||||
|
||||
// Wait for controller and informer to start up
|
||||
@ -287,7 +291,9 @@ func TestInformerNeverStarts(t *testing.T) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
stopReason := myController.Run(testContext)
|
||||
require.ErrorIs(t, stopReason, context.DeadlineExceeded)
|
||||
if !errors.Is(stopReason, context.Canceled) {
|
||||
t.Errorf("expected error to be context.Canceled, but got: %v", stopReason)
|
||||
}
|
||||
}()
|
||||
|
||||
// Wait for deadline to pass without syncing the cache
|
||||
@ -335,7 +341,9 @@ func TestIgnoredUpdate(t *testing.T) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
stopReason := myController.Run(testContext)
|
||||
require.ErrorIs(t, stopReason, context.Canceled)
|
||||
if !errors.Is(stopReason, context.Canceled) {
|
||||
t.Errorf("expected error to be context.Canceled, but got: %v", stopReason)
|
||||
}
|
||||
}()
|
||||
|
||||
// The controller is blocked because the reconcile function sends on an
|
||||
@ -392,7 +400,9 @@ func TestReconcileRetry(t *testing.T) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
stopReason := myController.Run(testContext)
|
||||
require.ErrorIs(t, stopReason, context.Canceled)
|
||||
if !errors.Is(stopReason, context.Canceled) {
|
||||
t.Errorf("expected error to be context.Canceled, but got: %v", stopReason)
|
||||
}
|
||||
}()
|
||||
|
||||
// Add object to informer
|
||||
|
@ -2197,7 +2197,9 @@ func TestWaitUntilWatchCacheFreshAndForceAllEvents(t *testing.T) {
|
||||
|
||||
go func(t *testing.T) {
|
||||
err := cacher.watchCache.Add(makeTestPodDetails("pod1", 105, "node1", map[string]string{"label": "value1"}))
|
||||
require.NoError(t, err, "failed adding a pod to the watchCache")
|
||||
if err != nil {
|
||||
t.Errorf("failed adding a pod to the watchCache %v", err)
|
||||
}
|
||||
}(t)
|
||||
w, err = cacher.Watch(context.Background(), "pods/ns", scenario.opts)
|
||||
require.NoError(t, err, "failed to create watch: %v")
|
||||
|
@ -57,10 +57,14 @@ func TestTunnelingHandler_UpgradeStreamingAndTunneling(t *testing.T) {
|
||||
defer close(stopServerChan)
|
||||
spdyServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
_, err := httpstream.Handshake(req, w, []string{constants.PortForwardV1Name})
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
upgrader := spdy.NewResponseUpgrader()
|
||||
conn := upgrader.UpgradeResponse(w, req, justQueueStream(streamChan))
|
||||
require.NotNil(t, conn)
|
||||
if conn == nil {
|
||||
t.Error("connect is unexpected nil")
|
||||
}
|
||||
defer conn.Close() //nolint:errcheck
|
||||
<-stopServerChan
|
||||
}))
|
||||
@ -97,9 +101,13 @@ func TestTunnelingHandler_UpgradeStreamingAndTunneling(t *testing.T) {
|
||||
var actual []byte
|
||||
go func() {
|
||||
clientStream, err := spdyClient.CreateStream(http.Header{})
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
_, err = io.Copy(clientStream, bytes.NewReader(randomData))
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
clientStream.Close() //nolint:errcheck
|
||||
}()
|
||||
select {
|
||||
@ -169,7 +177,9 @@ func TestTunnelingHandler_BadHandshakeError(t *testing.T) {
|
||||
spdyServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
// Handshake fails.
|
||||
_, err := httpstream.Handshake(req, w, []string{constants.PortForwardV1Name})
|
||||
require.Error(t, err, "handshake should have returned an error")
|
||||
if err == nil {
|
||||
t.Errorf("handshake should have returned an error %v", err)
|
||||
}
|
||||
assert.ErrorContains(t, err, "unable to negotiate protocol")
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
}))
|
||||
@ -223,7 +233,9 @@ func TestTunnelingHandler_UpstreamSPDYServerErrorPropagated(t *testing.T) {
|
||||
// Create fake upstream SPDY server, which returns a 500-level error.
|
||||
spdyServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
_, err := httpstream.Handshake(req, w, []string{constants.PortForwardV1Name})
|
||||
require.NoError(t, err, "handshake should have succeeded")
|
||||
if err != nil {
|
||||
t.Errorf("handshake should have succeeded %v", err)
|
||||
}
|
||||
// Returned status code should be incremented in metrics.
|
||||
w.WriteHeader(statusCode)
|
||||
}))
|
||||
|
@ -350,7 +350,9 @@ func TestCachedDiscoveryClientUnaggregatedServerGroups(t *testing.T) {
|
||||
return
|
||||
}
|
||||
output, err := json.Marshal(body)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
// Content-type is "unaggregated" discovery format -- no resources returned.
|
||||
w.Header().Set("Content-Type", discovery.AcceptV1)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
@ -587,7 +587,9 @@ func TestMemCacheGroupsAndMaybeResources(t *testing.T) {
|
||||
return
|
||||
}
|
||||
output, err := json.Marshal(body)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
// Content-type is "unaggregated" discovery format -- no resources returned.
|
||||
w.Header().Set("Content-Type", discovery.AcceptV1)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
@ -1116,7 +1118,9 @@ func TestAggregatedMemCacheGroupsAndMaybeResources(t *testing.T) {
|
||||
return
|
||||
}
|
||||
output, err := json.Marshal(agg)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
// Content-type is "aggregated" discovery format.
|
||||
w.Header().Set("Content-Type", discovery.AcceptV2)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
@ -1414,7 +1418,9 @@ func TestMemCacheAggregatedServerGroups(t *testing.T) {
|
||||
return
|
||||
}
|
||||
output, err := json.Marshal(agg)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
// Content-type is "aggregated" discovery format.
|
||||
w.Header().Set("Content-Type", discovery.AcceptV2Beta1)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
@ -60,7 +60,9 @@ func TestGetServerVersion(t *testing.T) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err = w.Write(output)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
@ -107,7 +109,9 @@ func TestGetServerGroupsWithV1Server(t *testing.T) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err = w.Write(output)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
@ -148,7 +152,9 @@ func TestDiscoveryToleratesMissingCoreGroup(t *testing.T) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err = w.Write(output)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
@ -185,7 +191,9 @@ func TestDiscoveryFailsWhenNonCoreGroupsMissing(t *testing.T) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err = w.Write(output)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
@ -386,7 +394,9 @@ func TestGetServerResourcesForGroupVersion(t *testing.T) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err = w.Write(output)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
for _, test := range tests {
|
||||
@ -1313,13 +1323,17 @@ func TestAggregatedServerGroups(t *testing.T) {
|
||||
return
|
||||
}
|
||||
output, err = json.Marshal(agg)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
// Content-Type is "aggregated" discovery format. Add extra parameter
|
||||
// to ensure we are resilient to these extra parameters.
|
||||
w.Header().Set("Content-Type", AcceptV2+"; charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err = w.Write(output)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
@ -2383,7 +2397,9 @@ func TestAggregatedServerGroupsAndResources(t *testing.T) {
|
||||
return
|
||||
}
|
||||
output, err = json.Marshal(agg)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
} else {
|
||||
var agg *apidiscoveryv2beta1.APIGroupDiscoveryList
|
||||
switch req.URL.Path {
|
||||
@ -2396,14 +2412,18 @@ func TestAggregatedServerGroupsAndResources(t *testing.T) {
|
||||
return
|
||||
}
|
||||
output, err = json.Marshal(&agg)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}
|
||||
// Content-Type is "aggregated" discovery format. Add extra parameter
|
||||
// to ensure we are resilient to these extra parameters.
|
||||
w.Header().Set("Content-Type", accept+"; charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err = w.Write(output)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
}))
|
||||
defer server.Close()
|
||||
@ -2543,13 +2563,17 @@ func TestAggregatedServerGroupsAndResourcesWithErrors(t *testing.T) {
|
||||
return
|
||||
}
|
||||
output, err = json.Marshal(agg)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
// Content-Type is "aggregated" discovery format. Add extra parameter
|
||||
// to ensure we are resilient to these extra parameters.
|
||||
w.Header().Set("Content-Type", AcceptV2+"; charset=utf-8")
|
||||
w.WriteHeader(status)
|
||||
_, err = w.Write(output)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
@ -3156,13 +3180,17 @@ func TestAggregatedServerPreferredResources(t *testing.T) {
|
||||
return
|
||||
}
|
||||
output, err = json.Marshal(agg)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
// Content-Type is "aggregated" discovery format. Add extra parameter
|
||||
// to ensure we are resilient to these extra parameters.
|
||||
w.Header().Set("Content-Type", AcceptV2+"; charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err = w.Write(output)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
|
@ -51,12 +51,18 @@ func TestTunnelingConnection_ReadWriteClose(t *testing.T) {
|
||||
Subprotocols: []string{constants.WebsocketsSPDYTunnelingPortForwardV1},
|
||||
}
|
||||
conn, err := upgrader.Upgrade(w, req, nil)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
defer conn.Close() //nolint:errcheck
|
||||
require.Equal(t, constants.WebsocketsSPDYTunnelingPortForwardV1, conn.Subprotocol())
|
||||
if conn.Subprotocol() != constants.WebsocketsSPDYTunnelingPortForwardV1 {
|
||||
t.Errorf("Not acceptable agreement Subprotocol: %v", conn.Subprotocol())
|
||||
}
|
||||
tunnelingConn := NewTunnelingConnection("server", conn)
|
||||
spdyConn, err := spdy.NewServerConnection(tunnelingConn, justQueueStream(streamChan))
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
defer spdyConn.Close() //nolint:errcheck
|
||||
<-stopServerChan
|
||||
}))
|
||||
@ -77,9 +83,13 @@ func TestTunnelingConnection_ReadWriteClose(t *testing.T) {
|
||||
var actual []byte
|
||||
go func() {
|
||||
clientStream, err := spdyClient.CreateStream(http.Header{})
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
_, err = io.Copy(clientStream, strings.NewReader(expected))
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
clientStream.Close() //nolint:errcheck
|
||||
}()
|
||||
select {
|
||||
@ -102,9 +112,13 @@ func TestTunnelingConnection_LocalRemoteAddress(t *testing.T) {
|
||||
Subprotocols: []string{constants.WebsocketsSPDYTunnelingPortForwardV1},
|
||||
}
|
||||
conn, err := upgrader.Upgrade(w, req, nil)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
defer conn.Close() //nolint:errcheck
|
||||
require.Equal(t, constants.WebsocketsSPDYTunnelingPortForwardV1, conn.Subprotocol())
|
||||
if conn.Subprotocol() != constants.WebsocketsSPDYTunnelingPortForwardV1 {
|
||||
t.Errorf("Not acceptable agreement Subprotocol: %v", conn.Subprotocol())
|
||||
}
|
||||
<-stopServerChan
|
||||
}))
|
||||
defer tunnelingServer.Close()
|
||||
@ -134,9 +148,13 @@ func TestTunnelingConnection_ReadWriteDeadlines(t *testing.T) {
|
||||
Subprotocols: []string{constants.WebsocketsSPDYTunnelingPortForwardV1},
|
||||
}
|
||||
conn, err := upgrader.Upgrade(w, req, nil)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
defer conn.Close() //nolint:errcheck
|
||||
require.Equal(t, constants.WebsocketsSPDYTunnelingPortForwardV1, conn.Subprotocol())
|
||||
if conn.Subprotocol() != constants.WebsocketsSPDYTunnelingPortForwardV1 {
|
||||
t.Errorf("Not acceptable agreement Subprotocol: %v", conn.Subprotocol())
|
||||
}
|
||||
<-stopServerChan
|
||||
}))
|
||||
defer tunnelingServer.Close()
|
||||
|
@ -49,7 +49,9 @@ func TestFallbackClient_WebSocketPrimarySucceeds(t *testing.T) {
|
||||
defer conns.conn.Close()
|
||||
// Loopback the STDIN stream onto the STDOUT stream.
|
||||
_, err = io.Copy(conns.stdoutStream, conns.stdinStream)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer websocketServer.Close()
|
||||
|
||||
@ -180,7 +182,9 @@ func TestFallbackClient_PrimaryAndSecondaryFail(t *testing.T) {
|
||||
defer conns.conn.Close()
|
||||
// Loopback the STDIN stream onto the STDOUT stream.
|
||||
_, err = io.Copy(conns.stdoutStream, conns.stdinStream)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
defer websocketServer.Close()
|
||||
|
||||
|
@ -113,12 +113,18 @@ func TestWebSocketRoundTripper_RoundTripperFails(t *testing.T) {
|
||||
}
|
||||
if testCase.status != nil {
|
||||
statusBytes, err := runtime.Encode(encoder, testCase.status)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
_, err = w.Write(statusBytes)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
} else if len(testCase.body) > 0 {
|
||||
_, err := w.Write([]byte(testCase.body))
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}
|
||||
}))
|
||||
defer websocketServer.Close()
|
||||
|
@ -393,13 +393,19 @@ func TestV2Beta1Skew(t *testing.T) {
|
||||
// Force a v2beta1 response from the aggregated apiserver
|
||||
v2b := apidiscoveryv2beta1.APIGroupDiscoveryList{}
|
||||
err := apidiscoveryv2scheme.Convertv2APIGroupDiscoveryListTov2beta1APIGroupDiscoveryList(&apiGroup, &v2b, nil)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
converted, err := json.Marshal(v2b)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json;"+"g=apidiscovery.k8s.io;v=v2beta1;as=APIGroupDiscoveryList")
|
||||
w.WriteHeader(200)
|
||||
_, err = w.Write(converted)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}))
|
||||
testCtx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
@ -348,7 +348,9 @@ func runRemoteCommandTest(t *testing.T, commandType string) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
exec, err := remotecommand.NewSPDYExecutor(&restclient.Config{}, "POST", reqURL)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
opts := remotecommand.StreamOptions{
|
||||
Stdin: stdinR,
|
||||
@ -356,7 +358,9 @@ func runRemoteCommandTest(t *testing.T, commandType string) {
|
||||
Stderr: stderrW,
|
||||
Tty: false,
|
||||
}
|
||||
require.NoError(t, exec.StreamWithContext(context.Background(), opts))
|
||||
if err = exec.StreamWithContext(context.Background(), opts); err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
|
@ -217,7 +217,9 @@ func TestReadinessAggregatedAPIServiceDiscovery(t *testing.T) {
|
||||
}
|
||||
}))
|
||||
go func() {
|
||||
require.NoError(t, service.Run(ctx))
|
||||
if err := service.Run(ctx); err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}()
|
||||
require.NoError(t, service.WaitForReady(ctx))
|
||||
|
||||
@ -306,7 +308,9 @@ func TestAggregatedAPIServiceDiscovery(t *testing.T) {
|
||||
}
|
||||
}))
|
||||
go func() {
|
||||
require.NoError(t, service.Run(ctx))
|
||||
if err := service.Run(ctx); err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}()
|
||||
require.NoError(t, service.WaitForReady(ctx))
|
||||
|
||||
|
@ -69,7 +69,9 @@ func TestSlowAPIServiceOpenAPIDoesNotBlockHealthCheck(t *testing.T) {
|
||||
http.ServeContent(w, r, "/openapi/v2", time.Now(), bytes.NewReader(data))
|
||||
}))
|
||||
go func() {
|
||||
require.NoError(t, service.Run(ctx))
|
||||
if err := service.Run(ctx); err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}()
|
||||
require.NoError(t, service.WaitForReady(ctx))
|
||||
|
||||
@ -131,7 +133,9 @@ func TestFetchingOpenAPIBeforeReady(t *testing.T) {
|
||||
http.ServeContent(w, r, "/openapi/v2", time.Now(), bytes.NewReader(data))
|
||||
}))
|
||||
go func() {
|
||||
require.NoError(t, service.Run(ctx))
|
||||
if err := service.Run(ctx); err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
}()
|
||||
require.NoError(t, service.WaitForReady(ctx))
|
||||
|
||||
|
@ -136,7 +136,9 @@ func BuildAndRunTestServer(t *testing.T, caPath, caKeyPath, issuerOverride strin
|
||||
writer.WriteHeader(http.StatusOK)
|
||||
|
||||
err = json.NewEncoder(writer).Encode(token)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
mux.HandleFunc(authWebPath, func(writer http.ResponseWriter, request *http.Request) {
|
||||
@ -150,7 +152,9 @@ func BuildAndRunTestServer(t *testing.T, caPath, caKeyPath, issuerOverride strin
|
||||
writer.WriteHeader(http.StatusOK)
|
||||
|
||||
err := json.NewEncoder(writer).Encode(keySet)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
return oidcServer
|
||||
|
Loading…
Reference in New Issue
Block a user