Commit 294a36a8 authored by Francisco Javier López's avatar Francisco Javier López Committed by Nick Thomas

Added endpoint to proxy connections to runner builds

In this MR we add two endpoints for proxying requests
to services running inside the runner's builds.

One of the endpoints is for regular HTTP requests, while
the other is for websockets.
parent be9f0805
......@@ -20,8 +20,9 @@ import (
)
var (
envTerminalPath = fmt.Sprintf("%s/environments/1/terminal.ws", testProject)
jobTerminalPath = fmt.Sprintf("%s/-/jobs/1/terminal.ws", testProject)
envTerminalPath = fmt.Sprintf("%s/environments/1/terminal.ws", testProject)
jobTerminalPath = fmt.Sprintf("%s/-/jobs/1/terminal.ws", testProject)
servicesProxyWSPath = fmt.Sprintf("%s/-/jobs/1/proxy.ws", testProject)
)
type connWithReq struct {
......@@ -36,6 +37,7 @@ func TestChannelHappyPath(t *testing.T) {
}{
{"environments", envTerminalPath},
{"jobs", jobTerminalPath},
{"services", servicesProxyWSPath},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
......@@ -74,15 +76,16 @@ func TestChannelHappyPath(t *testing.T) {
func TestChannelHappyPathWithTerminalResponse(t *testing.T) {
tests := []struct {
name string
terminalPath string
name string
channelPath string
}{
{"environments", envTerminalPath},
{"jobs", jobTerminalPath},
{"services", servicesProxyWSPath},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
serverConns, clientURL, close := wireupTerminal(test.terminalPath, nil, "channel.k8s.io")
serverConns, clientURL, close := wireupTerminal(test.channelPath, nil, "channel.k8s.io")
defer close()
client, _, err := dialWebsocket(clientURL, nil, "terminal.gitlab.com")
......
......@@ -190,6 +190,9 @@ func (u *upstream) configureRoutes() {
wsRoute(projectPattern+`environments/[0-9]+/terminal.ws\z`, channel.Handler(api)),
wsRoute(projectPattern+`-/jobs/[0-9]+/terminal.ws\z`, channel.Handler(api)),
// Proxy Job Services
wsRoute(projectPattern+`-/jobs/[0-9]+/proxy.ws\z`, channel.Handler(api)),
// Long poll and limit capacity given to jobs/request and builds/register.json
route("", apiPattern+`v4/jobs/request\z`, ciAPILongPolling),
route("", ciAPIPattern+`v1/builds/register.json\z`, ciAPILongPolling),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment