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
ae1e9bda
Commit
ae1e9bda
authored
Aug 16, 2017
by
Jacob Vosmaer (GitLab)
Committed by
Nick Thomas
Aug 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decorate local info refs and remove GitalyAddress
parent
7ab2ede6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
27 deletions
+22
-27
gitaly_test.go
gitaly_test.go
+8
-17
internal/api/api.go
internal/api/api.go
+0
-7
internal/git/info-refs.go
internal/git/info-refs.go
+11
-3
main_test.go
main_test.go
+3
-0
No files found.
gitaly_test.go
View file @
ae1e9bda
...
...
@@ -56,26 +56,20 @@ func TestGetInfoRefsProxiedToGitalySuccessfully(t *testing.T) {
gitalyAddress
:=
"unix://"
+
socketPath
apiResponseOld
:=
gitOkBody
(
t
)
apiResponseOld
.
GitalyServer
=
gitaly
.
Server
{}
apiResponseOld
.
GitalyAddress
=
gitalyAddress
apiResponse
:=
gitOkBody
(
t
)
apiResponse
.
GitalyServer
.
Address
=
gitalyAddress
for
_
,
a
:=
range
[]
*
api
.
Response
{
apiResponseOld
,
apiResponse
}
{
ts
:=
testAuthServer
(
nil
,
200
,
a
)
defer
ts
.
Close
()
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
resource
:=
"/gitlab-org/gitlab-test.git/info/refs?service=git-upload-pack"
_
,
body
:=
httpGet
(
t
,
ws
.
URL
+
resource
)
resource
:=
"/gitlab-org/gitlab-test.git/info/refs?service=git-upload-pack"
_
,
body
:=
httpGet
(
t
,
ws
.
URL
+
resource
)
expectedContent
:=
string
(
testhelper
.
GitalyInfoRefsResponseMock
)
assert
.
Equal
(
t
,
expectedContent
,
body
,
"GET %q: response body"
,
resource
)
}
expectedContent
:=
string
(
testhelper
.
GitalyInfoRefsResponseMock
)
assert
.
Equal
(
t
,
expectedContent
,
body
,
"GET %q: response body"
,
resource
)
}
func
TestGetInfoRefsProxiedToGitalyInterruptedStream
(
t
*
testing
.
T
)
{
...
...
@@ -265,7 +259,6 @@ func TestGetInfoRefsHandledLocallyDueToEmptyGitalySocketPath(t *testing.T) {
defer
gitalyServer
.
Stop
()
apiResponse
:=
gitOkBody
(
t
)
apiResponse
.
GitalyAddress
=
""
apiResponse
.
GitalyServer
.
Address
=
""
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
...
...
@@ -286,7 +279,6 @@ func TestPostReceivePackHandledLocallyDueToEmptyGitalySocketPath(t *testing.T) {
defer
gitalyServer
.
Stop
()
apiResponse
:=
gitOkBody
(
t
)
apiResponse
.
GitalyAddress
=
""
apiResponse
.
GitalyServer
.
Address
=
""
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
...
...
@@ -308,7 +300,6 @@ func TestPostUploadPackHandledLocallyDueToEmptyGitalySocketPath(t *testing.T) {
defer
gitalyServer
.
Stop
()
apiResponse
:=
gitOkBody
(
t
)
apiResponse
.
GitalyAddress
=
""
apiResponse
.
GitalyServer
.
Address
=
""
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
...
...
internal/api/api.go
View file @
ae1e9bda
...
...
@@ -105,8 +105,6 @@ type Response struct {
Entry
string
`json:"entry"`
// Used to communicate terminal session details
Terminal
*
TerminalSettings
// DEPRECATED. GitalyAddress is a unix:// or tcp:// address to reach a Gitaly service on
GitalyAddress
string
// GitalyServer specifies an address and authentication token for a gitaly server we should connect to.
GitalyServer
gitaly
.
Server
// Repository object for making gRPC requests to Gitaly. This will
...
...
@@ -231,11 +229,6 @@ func (api *API) PreAuthorize(suffix string, r *http.Request) (httpResponse *http
return
httpResponse
,
nil
,
fmt
.
Errorf
(
"preAuthorizeHandler: decode authorization response: %v"
,
err
)
}
if
authResponse
.
GitalyServer
.
Address
==
""
{
authResponse
.
GitalyServer
.
Address
=
authResponse
.
GitalyAddress
}
authResponse
.
GitalyAddress
=
""
return
httpResponse
,
authResponse
,
nil
}
...
...
internal/git/info-refs.go
View file @
ae1e9bda
...
...
@@ -11,6 +11,11 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
var
(
// Testing is only set during workhorse testing.
Testing
=
false
)
func
GetInfoRefsHandler
(
a
*
api
.
API
)
http
.
Handler
{
return
repoPreAuthorizeHandler
(
a
,
handleGetInfoRefs
)
}
...
...
@@ -31,8 +36,8 @@ func handleGetInfoRefs(rw http.ResponseWriter, r *http.Request, a *api.Response)
w
.
Header
()
.
Set
(
"Cache-Control"
,
"no-cache"
)
var
err
error
if
a
.
GitalyServer
.
Address
==
""
{
err
=
handleGetInfoRefsLocal
ly
(
w
,
a
,
rpc
)
if
a
.
GitalyServer
.
Address
==
""
&&
Testing
{
err
=
handleGetInfoRefsLocal
Testing
(
w
,
a
,
rpc
)
}
else
{
err
=
handleGetInfoRefsWithGitaly
(
r
.
Context
(),
w
,
a
,
rpc
)
}
...
...
@@ -42,7 +47,10 @@ func handleGetInfoRefs(rw http.ResponseWriter, r *http.Request, a *api.Response)
}
}
func
handleGetInfoRefsLocally
(
w
http
.
ResponseWriter
,
a
*
api
.
Response
,
rpc
string
)
error
{
// This code is not used in production. It is left over from before
// Gitaly. We left it here to allow local workhorse tests to keep working
// until we are done migrating Git HTTP to Gitaly.
func
handleGetInfoRefsLocalTesting
(
w
http
.
ResponseWriter
,
a
*
api
.
Response
,
rpc
string
)
error
{
if
err
:=
pktLine
(
w
,
fmt
.
Sprintf
(
"# service=%s
\n
"
,
rpc
));
err
!=
nil
{
return
fmt
.
Errorf
(
"pktLine: %v"
,
err
)
}
...
...
main_test.go
View file @
ae1e9bda
...
...
@@ -20,6 +20,7 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/config"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/git"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/gitaly"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
...
...
@@ -41,6 +42,8 @@ var checkoutDir = path.Join(scratchDir, "test")
var
cacheDir
=
path
.
Join
(
scratchDir
,
"cache"
)
func
TestMain
(
m
*
testing
.
M
)
{
git
.
Testing
=
true
source
:=
"https://gitlab.com/gitlab-org/gitlab-test.git"
clonePath
:=
path
.
Join
(
testRepoRoot
,
testRepo
)
if
_
,
err
:=
os
.
Stat
(
clonePath
);
err
!=
nil
{
...
...
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