Commit 8b613a84 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'fj-proxy-webide-services' into 'master'

Add new endpoint to add support to proxy websocket requests to build's services

Closes #205 and gitlab-ee#5276

See merge request gitlab-org/gitlab-workhorse!370
parents be9f0805 294a36a8
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
var ( var (
envTerminalPath = fmt.Sprintf("%s/environments/1/terminal.ws", testProject) envTerminalPath = fmt.Sprintf("%s/environments/1/terminal.ws", testProject)
jobTerminalPath = fmt.Sprintf("%s/-/jobs/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 { type connWithReq struct {
...@@ -36,6 +37,7 @@ func TestChannelHappyPath(t *testing.T) { ...@@ -36,6 +37,7 @@ func TestChannelHappyPath(t *testing.T) {
}{ }{
{"environments", envTerminalPath}, {"environments", envTerminalPath},
{"jobs", jobTerminalPath}, {"jobs", jobTerminalPath},
{"services", servicesProxyWSPath},
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
...@@ -75,14 +77,15 @@ func TestChannelHappyPath(t *testing.T) { ...@@ -75,14 +77,15 @@ func TestChannelHappyPath(t *testing.T) {
func TestChannelHappyPathWithTerminalResponse(t *testing.T) { func TestChannelHappyPathWithTerminalResponse(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
terminalPath string channelPath string
}{ }{
{"environments", envTerminalPath}, {"environments", envTerminalPath},
{"jobs", jobTerminalPath}, {"jobs", jobTerminalPath},
{"services", servicesProxyWSPath},
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { 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() defer close()
client, _, err := dialWebsocket(clientURL, nil, "terminal.gitlab.com") client, _, err := dialWebsocket(clientURL, nil, "terminal.gitlab.com")
......
...@@ -190,6 +190,9 @@ func (u *upstream) configureRoutes() { ...@@ -190,6 +190,9 @@ func (u *upstream) configureRoutes() {
wsRoute(projectPattern+`environments/[0-9]+/terminal.ws\z`, channel.Handler(api)), wsRoute(projectPattern+`environments/[0-9]+/terminal.ws\z`, channel.Handler(api)),
wsRoute(projectPattern+`-/jobs/[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 // Long poll and limit capacity given to jobs/request and builds/register.json
route("", apiPattern+`v4/jobs/request\z`, ciAPILongPolling), route("", apiPattern+`v4/jobs/request\z`, ciAPILongPolling),
route("", ciAPIPattern+`v1/builds/register.json\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