Skip to content

Commit

Permalink
chore(tests): Add a test to verify if the principal can handle both W…
Browse files Browse the repository at this point in the history
…ebSocket and regular gRPC requests (#198)

Signed-off-by: Chetan Banavikalmutt <[email protected]>
  • Loading branch information
chetan-rns authored Oct 9, 2024
1 parent 586883c commit b935f36
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func Test_WithHTTP1WebSocket(t *testing.T) {

// Create a reverse proxy that downgrades the incoming requests to HTTP/1.1
http1Proxy := proxy.StartHTTP2DowngradingProxy(t, hostPort("", proxyPort), hostPort("", s.ListenerForE2EOnly().Port()))
defer http1Proxy.Close()
defer http1Proxy.Shutdown(sctx)

// Create a remote agent with WebSocket disabled
remote := createRemote(t, false, proxyPort)
Expand All @@ -409,7 +409,7 @@ func Test_WithHTTP1WebSocket(t *testing.T) {

// Create a reverse proxy that downgrades the incoming requests to HTTP/1.1
http1Proxy := proxy.StartHTTP2DowngradingProxy(t, hostPort("", proxyPort), hostPort("", s.ListenerForE2EOnly().Port()))
defer http1Proxy.Close()
defer http1Proxy.Shutdown(sctx)

// Create an agent with WebSocket enabled
remote, a := startAgent(t, actx, createRemote(t, true, proxyPort))
Expand Down Expand Up @@ -442,6 +442,27 @@ func Test_WithHTTP1WebSocket(t *testing.T) {
_, err = fakeAppcServer.ArgoprojV1alpha1().Applications("client").Update(actx, app, v1.UpdateOptions{})
require.NoError(t, err)
})

t.Run("principal with WebSocket enabled should also support agents that use raw gRPC", func(t *testing.T) {
// Check if the principal with WebSocket enabled can also handle raw gRPC requests
// from agents that are not behind HTTP/1.1 proxy.
sctx, scancel := context.WithTimeout(context.Background(), 20*time.Second)
actx, acancel := context.WithTimeout(context.Background(), 20*time.Second)
defer scancel()
defer acancel()

// Create the principal server with WebSocket enabled.
s := startPrincipal(t, sctx, true)
defer s.Shutdown()

// Create an agent with WebSocket disabled that is not behind a proxy. The agent will use a regular gRPC client.
remote, a := startAgent(t, actx, createRemote(t, false, s.ListenerForE2EOnly().Port()))
defer a.Stop()

// The agent should be able to connect to the principal via regular gRPC.
require.NoError(t, remote.Connect(actx, false))
require.True(t, a.IsConnected())
})
}

func log() *logrus.Entry {
Expand Down

0 comments on commit b935f36

Please sign in to comment.