Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-runner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Seipel
gitlab-runner
Commits
b00023e5
Unverified
Commit
b00023e5
authored
6 years ago
by
Steve Azzopardi
Browse files
Options
Downloads
Patches
Plain Diff
Refactor docker terminal tests
parent
11d02d05
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
executors/docker/terminal.go
+2
-1
2 additions, 1 deletion
executors/docker/terminal.go
executors/docker/terminal_test.go
+21
-13
21 additions, 13 deletions
executors/docker/terminal_test.go
with
23 additions
and
14 deletions
executors/docker/terminal.go
+
2
−
1
View file @
b00023e5
...
...
@@ -8,6 +8,7 @@ import (
"time"
"github.com/docker/docker/api/types"
"gitlab.com/gitlab-org/gitlab-runner/common"
"gitlab.com/gitlab-org/gitlab-runner/helpers/docker"
terminalsession
"gitlab.com/gitlab-org/gitlab-runner/session/terminal"
...
...
@@ -95,7 +96,7 @@ func (t terminalConn) Start(w http.ResponseWriter, r *http.Request, timeoutCh, d
exec
,
err
:=
t
.
client
.
ContainerExecCreate
(
t
.
ctx
,
t
.
containerID
,
execConfig
)
if
err
!=
nil
{
t
.
logger
.
Errorln
(
"Failed to create exec container for terminal:"
,
err
)
http
.
Error
(
w
,
"failed to create exec
to
build container"
,
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
"failed to create exec
for
build container"
,
http
.
StatusInternalServerError
)
return
}
...
...
This diff is collapsed.
Click to expand it.
executors/docker/terminal_test.go
+
21
−
13
View file @
b00023e5
...
...
@@ -67,23 +67,23 @@ func TestInteractiveTerminal(t *testing.T) {
"Authorization"
:
[]
string
{
build
.
Session
.
Token
},
}
var
retries
int
var
webSocket
*
websocket
.
Conn
for
retries
<
500
{
conn
,
resp
,
err
:=
websocket
.
DefaultDialer
.
Dial
(
u
.
String
(),
headers
)
if
err
!=
nil
{
retries
++
time
.
Sleep
(
50
*
time
.
Millisecond
)
continue
var
resp
*
http
.
Response
started
:=
time
.
Now
()
for
time
.
Since
(
started
)
<
25
*
time
.
Second
{
webSocket
,
resp
,
err
=
websocket
.
DefaultDialer
.
Dial
(
u
.
String
(),
headers
)
if
err
==
nil
{
break
}
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
conn
)
require
.
Equal
(
t
,
http
.
StatusSwitchingProtocols
,
resp
.
StatusCode
)
webSocket
=
conn
break
time
.
Sleep
(
50
*
time
.
Millisecond
)
}
require
.
NotNil
(
t
,
webSocket
)
require
.
Equal
(
t
,
http
.
StatusSwitchingProtocols
,
resp
.
StatusCode
)
defer
webSocket
.
Close
()
err
=
webSocket
.
WriteMessage
(
websocket
.
BinaryMessage
,
[]
byte
(
"uname
\n
"
))
...
...
@@ -406,7 +406,15 @@ func TestTerminalConn_Start(t *testing.T) {
}
}()
time
.
Sleep
(
5
*
time
.
Second
)
started
:=
time
.
Now
()
for
time
.
Since
(
started
)
<
5
*
time
.
Second
{
if
!
session
.
Connected
()
{
break
}
time
.
Sleep
(
50
*
time
.
Microsecond
)
}
assert
.
False
(
t
,
session
.
Connected
())
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment