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
8eb21608
Commit
8eb21608
authored
Jan 20, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integration: Add tests for HTTP/2 backend using go-nghttp2
parent
a440bdf1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
1 deletion
+89
-1
README.rst
README.rst
+23
-0
configure.ac
configure.ac
+1
-0
integration-tests/nghttpx_test.go
integration-tests/nghttpx_test.go
+37
-0
integration-tests/server_tester.go
integration-tests/server_tester.go
+22
-1
integration-tests/setenv.in
integration-tests/setenv.in
+6
-0
No files found.
README.rst
View file @
8eb21608
...
...
@@ -172,6 +172,29 @@ The generated documents will not be installed with ``make install``.
The online documentation is available at
https://nghttp2.org/documentation/
Unit tests
----------
Unit tests are done by simply running `make check`.
Integration tests
-----------------
We have the integration tests for nghttpx proxy server. The tests are
written in `Go programming language <http://golang.org/>`_ and uses
its testing framework. We depends on the following libraries:
* https://github.com/bradfitz/http2
* https://github.com/tatsuhiro-t/go-nghttp2
To run the tests, enter ``integration-tests`` directory and run::
$ sh setenv go test
``setenv`` will set necessary environment variables to compile
go-nghttp2 library (which uses cgo to interface nghttp2). In side the
tests, we use port 3009 to run test subject server.
Client, Server and Proxy programs
---------------------------------
...
...
configure.ac
View file @
8eb21608
...
...
@@ -652,6 +652,7 @@ AC_CONFIG_FILES([
python/Makefile
python/setup.py
integration-tests/config.go
integration-tests/setenv
doc/Makefile
doc/conf.py
doc/index.rst
...
...
integration-tests/nghttpx_test.go
View file @
8eb21608
...
...
@@ -240,3 +240,40 @@ func TestHTTP2InvalidRequestCL(t *testing.T) {
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestHTTP2DuplicateResponseCL
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Header
()
.
Add
(
"content-length"
,
"1"
)
w
.
Header
()
.
Add
(
"content-length"
,
"2"
)
})
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestHTTP2DuplicateResponseCL"
,
})
if
err
!=
nil
{
t
.
Errorf
(
"Error st.http2() = %v"
,
err
)
}
want
:=
502
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestHTTP2InvalidResponseCL
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Header
()
.
Add
(
"content-length"
,
""
)
})
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestHTTP2InvalidResponseCL"
,
})
if
err
!=
nil
{
t
.
Errorf
(
"Error st.http2() = %v"
,
err
)
}
want
:=
502
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
integration-tests/server_tester.go
View file @
8eb21608
...
...
@@ -2,10 +2,12 @@ package nghttp2
import
(
"bytes"
"crypto/tls"
"errors"
"fmt"
"github.com/bradfitz/http2"
"github.com/bradfitz/http2/hpack"
"github.com/tatsuhiro-t/go-nghttp2"
"net"
"net/http"
"net/http/httptest"
...
...
@@ -48,8 +50,27 @@ type serverTester struct {
}
func
newServerTester
(
args
[]
string
,
t
*
testing
.
T
,
handler
http
.
HandlerFunc
)
*
serverTester
{
ts
:=
httptest
.
NewServer
(
handler
)
ts
:=
httptest
.
New
Unstarted
Server
(
handler
)
backendTLS
:=
false
for
_
,
k
:=
range
args
{
if
k
==
"--http2-bridge"
{
backendTLS
=
true
break
}
}
if
backendTLS
{
nghttp2
.
ConfigureServer
(
ts
.
Config
,
&
nghttp2
.
Server
{})
// According to httptest/server.go, we have to set
// NextProtos separately for ts.TLS. NextProtos set
// in nghttp2.ConfigureServer is effectively ignored.
ts
.
TLS
=
new
(
tls
.
Config
)
ts
.
TLS
.
NextProtos
=
append
(
ts
.
TLS
.
NextProtos
,
"h2-14"
)
ts
.
StartTLS
()
args
=
append
(
args
,
"-k"
)
}
else
{
ts
.
Start
()
}
u
,
err
:=
url
.
Parse
(
ts
.
URL
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error parsing URL from httptest.Server: %v"
,
err
)
...
...
integration-tests/setenv.in
0 → 100644
View file @
8eb21608
#!/bin/sh -e
export
CGO_CFLAGS
=
"-I@abs_top_srcdir@/lib/includes -I@abs_top_builddir@/lib/includes"
export
CGO_LDFLAGS
=
"-L@abs_top_builddir@/lib/.libs"
export
LD_LIBRARY_PATH
=
"@abs_top_builddir@/lib/.libs"
"
$@
"
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