Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
b4acd08e
Commit
b4acd08e
authored
Mar 22, 2017
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a separate Gitaly socket for every test
parent
2b604f62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
main_test.go
main_test.go
+20
-16
No files found.
main_test.go
View file @
b4acd08e
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"io"
"io"
"io/ioutil"
"io/ioutil"
"log"
"log"
"math/rand"
"net"
"net"
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
...
@@ -38,7 +39,6 @@ const testProject = "group/test"
...
@@ -38,7 +39,6 @@ const testProject = "group/test"
var
checkoutDir
=
path
.
Join
(
scratchDir
,
"test"
)
var
checkoutDir
=
path
.
Join
(
scratchDir
,
"test"
)
var
cacheDir
=
path
.
Join
(
scratchDir
,
"cache"
)
var
cacheDir
=
path
.
Join
(
scratchDir
,
"cache"
)
var
gitalySocketPath
=
path
.
Join
(
scratchDir
,
"gitaly.sock"
)
func
TestMain
(
m
*
testing
.
M
)
{
func
TestMain
(
m
*
testing
.
M
)
{
source
:=
"https://gitlab.com/gitlab-org/gitlab-test.git"
source
:=
"https://gitlab.com/gitlab-org/gitlab-test.git"
...
@@ -60,6 +60,8 @@ func TestMain(m *testing.M) {
...
@@ -60,6 +60,8 @@ func TestMain(m *testing.M) {
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
defer
gitaly
.
CloseConnections
()
os
.
Exit
(
func
()
int
{
os
.
Exit
(
func
()
int
{
defer
cleanup
()
defer
cleanup
()
return
m
.
Run
()
return
m
.
Run
()
...
@@ -594,15 +596,19 @@ func TestApiContentTypeBlock(t *testing.T) {
...
@@ -594,15 +596,19 @@ func TestApiContentTypeBlock(t *testing.T) {
}
}
func
TestGetInfoRefsProxiedToGitalySuccessfully
(
t
*
testing
.
T
)
{
func
TestGetInfoRefsProxiedToGitalySuccessfully
(
t
*
testing
.
T
)
{
gitalyServer
:=
startGitalyServer
(
t
)
defer
func
()
{
gitalyServer
.
Stop
()
gitaly
.
CloseConnections
()
}()
apiResponse
:=
gitOkBody
(
t
)
apiResponse
:=
gitOkBody
(
t
)
repoPath
:=
apiResponse
.
RepoPath
repoPath
:=
apiResponse
.
RepoPath
gitalyServer
,
socketPath
:=
startGitalyServer
(
t
)
defer
gitalyServer
.
Stop
()
apiResponse
.
GitalySocketPath
=
socketPath
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
for
_
,
testCase
:=
range
[]
struct
{
for
_
,
testCase
:=
range
[]
struct
{
repoPath
string
repoPath
string
repository
pb
.
Repository
repository
pb
.
Repository
...
@@ -613,7 +619,7 @@ func TestGetInfoRefsProxiedToGitalySuccessfully(t *testing.T) {
...
@@ -613,7 +619,7 @@ func TestGetInfoRefsProxiedToGitalySuccessfully(t *testing.T) {
func
()
{
func
()
{
apiResponse
.
RepoPath
=
testCase
.
repoPath
apiResponse
.
RepoPath
=
testCase
.
repoPath
apiResponse
.
Repository
=
testCase
.
repository
apiResponse
.
Repository
=
testCase
.
repository
apiResponse
.
GitalySocketPath
=
gitalyS
ocketPath
apiResponse
.
GitalySocketPath
=
s
ocketPath
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
defer
ts
.
Close
()
...
@@ -640,11 +646,8 @@ func TestGetInfoRefsProxiedToGitalySuccessfully(t *testing.T) {
...
@@ -640,11 +646,8 @@ func TestGetInfoRefsProxiedToGitalySuccessfully(t *testing.T) {
}
}
func
TestGetInfoRefsHandledLocallyDueToEmptyGitalySocketPath
(
t
*
testing
.
T
)
{
func
TestGetInfoRefsHandledLocallyDueToEmptyGitalySocketPath
(
t
*
testing
.
T
)
{
gitalyServer
:=
startGitalyServer
(
t
)
gitalyServer
,
_
:=
startGitalyServer
(
t
)
defer
func
()
{
defer
gitalyServer
.
Stop
()
gitalyServer
.
Stop
()
gitaly
.
CloseConnections
()
}()
apiResponse
:=
gitOkBody
(
t
)
apiResponse
:=
gitOkBody
(
t
)
apiResponse
.
GitalySocketPath
=
""
apiResponse
.
GitalySocketPath
=
""
...
@@ -848,9 +851,10 @@ func startWorkhorseServerWithConfig(cfg *config.Config) *httptest.Server {
...
@@ -848,9 +851,10 @@ func startWorkhorseServerWithConfig(cfg *config.Config) *httptest.Server {
return
httptest
.
NewServer
(
u
)
return
httptest
.
NewServer
(
u
)
}
}
func
startGitalyServer
(
t
*
testing
.
T
)
*
grpc
.
Server
{
func
startGitalyServer
(
t
*
testing
.
T
)
(
*
grpc
.
Server
,
string
)
{
socketPath
:=
path
.
Join
(
scratchDir
,
fmt
.
Sprintf
(
"gitaly-%d.sock"
,
rand
.
Int
()))
server
:=
grpc
.
NewServer
()
server
:=
grpc
.
NewServer
()
listener
,
err
:=
net
.
Listen
(
"unix"
,
gitalyS
ocketPath
)
listener
,
err
:=
net
.
Listen
(
"unix"
,
s
ocketPath
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -859,7 +863,7 @@ func startGitalyServer(t *testing.T) *grpc.Server {
...
@@ -859,7 +863,7 @@ func startGitalyServer(t *testing.T) *grpc.Server {
go
server
.
Serve
(
listener
)
go
server
.
Serve
(
listener
)
return
server
return
server
,
socketPath
}
}
func
runOrFail
(
t
*
testing
.
T
,
cmd
*
exec
.
Cmd
)
{
func
runOrFail
(
t
*
testing
.
T
,
cmd
*
exec
.
Cmd
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment