Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
e007b6b0
Commit
e007b6b0
authored
Dec 11, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DNS integration tests
parent
c487cd88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
3 deletions
+96
-3
integration-tests/nghttpx_http2_test.go
integration-tests/nghttpx_http2_test.go
+72
-0
integration-tests/server_tester.go
integration-tests/server_tester.go
+24
-3
No files found.
integration-tests/nghttpx_http2_test.go
View file @
e007b6b0
...
...
@@ -1369,6 +1369,42 @@ func TestH2H1ProxyProtocolV1InvalidID(t *testing.T) {
}
}
// TestH2H1ExternalDNS tests that DNS resolution using external DNS
// with HTTP/1 backend works.
func
TestH2H1ExternalDNS
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--external-dns"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H1ExternalDNS"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
// TestH2H1DNS tests that DNS resolution without external DNS with
// HTTP/1 backend works.
func
TestH2H1DNS
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--dns"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H1DNS"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
// TestH2H1GracefulShutdown tests graceful shutdown.
func
TestH2H1GracefulShutdown
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
...
...
@@ -1845,6 +1881,42 @@ func TestH2H2RespPhaseReturn(t *testing.T) {
}
}
// TestH2H2ExternalDNS tests that DNS resolution using external DNS
// with HTTP/2 backend works.
func
TestH2H2ExternalDNS
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
,
"--external-dns"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H2ExternalDNS"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
// TestH2H2DNS tests that DNS resolution without external DNS with
// HTTP/2 backend works.
func
TestH2H2DNS
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
,
"--dns"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H2DNS"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
// TestH2APIBackendconfig exercise backendconfig API endpoint routine
// for successful case.
func
TestH2APIBackendconfig
(
t
*
testing
.
T
)
{
...
...
integration-tests/server_tester.go
View file @
e007b6b0
...
...
@@ -101,10 +101,17 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
args
:=
[]
string
{}
backendTLS
:=
false
dns
:=
false
externalDNS
:=
false
for
_
,
k
:=
range
src_args
{
switch
k
{
case
"--http2-bridge"
:
backendTLS
=
true
case
"--dns"
:
dns
=
true
case
"--external-dns"
:
dns
=
true
externalDNS
=
true
default
:
args
=
append
(
args
,
k
)
}
...
...
@@ -117,7 +124,7 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
ts
.
TLS
=
new
(
tls
.
Config
)
ts
.
TLS
.
NextProtos
=
append
(
ts
.
TLS
.
NextProtos
,
"h2"
)
ts
.
StartTLS
()
args
=
append
(
args
,
"-k"
,
"--backend-tls"
)
args
=
append
(
args
,
"-k"
)
}
else
{
ts
.
Start
()
}
...
...
@@ -134,9 +141,23 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
// URL.Host looks like "127.0.0.1:8080", but we want
// "127.0.0.1,8080"
b
:=
"-b"
+
strings
.
Replace
(
backendURL
.
Host
,
":"
,
","
,
-
1
)
b
:=
"-b"
if
!
externalDNS
{
b
+=
fmt
.
Sprintf
(
"%v;"
,
strings
.
Replace
(
backendURL
.
Host
,
":"
,
","
,
-
1
))
}
else
{
sep
:=
strings
.
LastIndex
(
backendURL
.
Host
,
":"
)
if
sep
==
-
1
{
t
.
Fatalf
(
"backendURL.Host %v does not contain separator ':'"
,
backendURL
.
Host
)
}
// We use awesome service xip.io.
b
+=
fmt
.
Sprintf
(
"%v.xip.io,%v;"
,
backendURL
.
Host
[
:
sep
],
backendURL
.
Host
[
sep
+
1
:
])
}
if
backendTLS
{
b
+=
";;proto=h2;tls"
b
+=
";proto=h2;tls"
}
if
dns
{
b
+=
";dns"
}
noTLS
:=
"no-tls"
...
...
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