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
990f9ed4
Commit
990f9ed4
authored
Jan 23, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integration: Split up single file to 3 based on frontend type
parent
0f4b0966
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
291 additions
and
269 deletions
+291
-269
integration-tests/Makefile.am
integration-tests/Makefile.am
+7
-2
integration-tests/nghttpx_http1_test.go
integration-tests/nghttpx_http1_test.go
+173
-0
integration-tests/nghttpx_http2_test.go
integration-tests/nghttpx_http2_test.go
+0
-267
integration-tests/nghttpx_spdy_test.go
integration-tests/nghttpx_spdy_test.go
+111
-0
No files found.
integration-tests/Makefile.am
View file @
990f9ed4
...
...
@@ -22,8 +22,13 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
EXTRA_DIST
=
\
nghttpx_test.go
\
server_tester.go
nghttpx_http1_test.go
\
nghttpx_http2_test.go
\
nghttpx_spdy_test.go
\
server_tester.go
\
server.key
\
server.crt
\
setenv
.PHONY
:
itprep it
...
...
integration-tests/nghttpx_http1_test.go
0 → 100644
View file @
990f9ed4
package
nghttp2
import
(
"bufio"
"fmt"
"github.com/bradfitz/http2/hpack"
"io"
"net/http"
"syscall"
"testing"
)
func
TestH1H1PlainGET
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H1PlainGET"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
want
:=
200
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
func
TestH1H1PlainGETClose
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H1PlainGETClose"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"Connection"
,
"close"
),
},
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
want
:=
200
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
func
TestH1H1MultipleRequestCL
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Errorf
(
"server should not forward bad request"
)
})
defer
st
.
Close
()
if
_
,
err
:=
io
.
WriteString
(
st
.
conn
,
fmt
.
Sprintf
(
`GET / HTTP/1.1
Host: %v
Test-Case: TestH1H1MultipleRequestCL
Content-Length: 0
Content-Length: 1
`
,
st
.
authority
));
err
!=
nil
{
t
.
Fatalf
(
"Error io.WriteString() = %v"
,
err
)
}
resp
,
err
:=
http
.
ReadResponse
(
bufio
.
NewReader
(
st
.
conn
),
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error http.ReadResponse() = %v"
,
err
)
}
want
:=
400
if
got
:=
resp
.
StatusCode
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestH1H1ConnectFailure
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
// shutdown backend server to simulate backend connect failure
st
.
ts
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H1ConnectFailure"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
want
:=
503
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestH1H1GracefulShutdown
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H1GracefulShutdown-1"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
st
.
cmd
.
Process
.
Signal
(
syscall
.
SIGQUIT
)
res
,
err
=
st
.
http1
(
requestParam
{
name
:
"TestH1H1GracefulShutdown-2"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
if
got
,
want
:=
res
.
connClose
,
true
;
got
!=
want
{
t
.
Errorf
(
"res.connClose: %v; want %v"
,
got
,
want
)
}
want
:=
io
.
EOF
if
_
,
err
:=
st
.
conn
.
Read
(
nil
);
err
==
nil
||
err
!=
want
{
t
.
Errorf
(
"st.conn.Read(): %v; want %v"
,
err
,
want
)
}
}
func
TestH1H2ConnectFailure
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
},
t
,
noopHandler
)
defer
st
.
Close
()
// simulate backend connect attempt failure
st
.
ts
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H2ConnectFailure"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
want
:=
503
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestH1H2NoHost
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Errorf
(
"server should not forward bad request"
)
})
defer
st
.
Close
()
// without Host header field, we expect 400 response
if
_
,
err
:=
io
.
WriteString
(
st
.
conn
,
"GET / HTTP/1.1
\r\n
Test-Case: TestH1H2NoHost
\r\n\r\n
"
);
err
!=
nil
{
t
.
Fatalf
(
"Error io.WriteString() = %v"
,
err
)
}
resp
,
err
:=
http
.
ReadResponse
(
bufio
.
NewReader
(
st
.
conn
),
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error http.ReadResponse() = %v"
,
err
)
}
want
:=
400
if
got
:=
resp
.
StatusCode
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
integration-tests/nghttpx_test.go
→
integration-tests/nghttpx_
http2_
test.go
View file @
990f9ed4
package
nghttp2
import
(
"bufio"
"fmt"
"github.com/bradfitz/http2"
"github.com/bradfitz/http2/hpack"
"golang.org/x/net/spdy"
"io"
"io/ioutil"
"net/http"
...
...
@@ -13,168 +11,6 @@ import (
"testing"
)
func
TestH1H1PlainGET
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H1PlainGET"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
want
:=
200
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
func
TestH1H1PlainGETClose
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H1PlainGETClose"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"Connection"
,
"close"
),
},
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
want
:=
200
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
func
TestH1H1MultipleRequestCL
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Errorf
(
"server should not forward bad request"
)
})
defer
st
.
Close
()
if
_
,
err
:=
io
.
WriteString
(
st
.
conn
,
fmt
.
Sprintf
(
`GET / HTTP/1.1
Host: %v
Test-Case: TestH1H1MultipleRequestCL
Content-Length: 0
Content-Length: 1
`
,
st
.
authority
));
err
!=
nil
{
t
.
Fatalf
(
"Error io.WriteString() = %v"
,
err
)
}
resp
,
err
:=
http
.
ReadResponse
(
bufio
.
NewReader
(
st
.
conn
),
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error http.ReadResponse() = %v"
,
err
)
}
want
:=
400
if
got
:=
resp
.
StatusCode
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestH1H1ConnectFailure
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
// shutdown backend server to simulate backend connect failure
st
.
ts
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H1ConnectFailure"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
want
:=
503
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestH1H1GracefulShutdown
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H1GracefulShutdown-1"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
st
.
cmd
.
Process
.
Signal
(
syscall
.
SIGQUIT
)
res
,
err
=
st
.
http1
(
requestParam
{
name
:
"TestH1H1GracefulShutdown-2"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
if
got
,
want
:=
res
.
connClose
,
true
;
got
!=
want
{
t
.
Errorf
(
"res.connClose: %v; want %v"
,
got
,
want
)
}
want
:=
io
.
EOF
if
_
,
err
:=
st
.
conn
.
Read
(
nil
);
err
==
nil
||
err
!=
want
{
t
.
Errorf
(
"st.conn.Read(): %v; want %v"
,
err
,
want
)
}
}
func
TestH1H2ConnectFailure
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
},
t
,
noopHandler
)
defer
st
.
Close
()
// simulate backend connect attempt failure
st
.
ts
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H2ConnectFailure"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
want
:=
503
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestH1H2NoHost
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Errorf
(
"server should not forward bad request"
)
})
defer
st
.
Close
()
// without Host header field, we expect 400 response
if
_
,
err
:=
io
.
WriteString
(
st
.
conn
,
"GET / HTTP/1.1
\r\n
Test-Case: TestH1H2NoHost
\r\n\r\n
"
);
err
!=
nil
{
t
.
Fatalf
(
"Error io.WriteString() = %v"
,
err
)
}
resp
,
err
:=
http
.
ReadResponse
(
bufio
.
NewReader
(
st
.
conn
),
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error http.ReadResponse() = %v"
,
err
)
}
want
:=
400
if
got
:=
resp
.
StatusCode
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestH2H1PlainGET
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
defer
st
.
Close
()
...
...
@@ -561,106 +397,3 @@ func TestH2H2ConnectFailure(t *testing.T) {
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestS3H1PlainGET
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H1PlainGET"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
200
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
func
TestS3H1BadRequestCL
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
},
t
,
noopHandler
)
defer
st
.
Close
()
// we set content-length: 1024, but the actual request body is
// 3 bytes.
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H1BadRequestCL"
,
method
:
"POST"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"content-length"
,
"1024"
),
},
body
:
[]
byte
(
"foo"
),
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
spdy
.
ProtocolError
if
got
:=
res
.
spdyRstErrCode
;
got
!=
want
{
t
.
Errorf
(
"res.spdyRstErrCode = %v; want %v"
,
got
,
want
)
}
}
func
TestS3H1MultipleRequestCL
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Errorf
(
"server should not forward bad request"
)
})
defer
st
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H1MultipleRequestCL"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"content-length"
,
"1"
),
pair
(
"content-length"
,
"2"
),
},
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
400
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestS3H1InvalidRequestCL
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Errorf
(
"server should not forward bad request"
)
})
defer
st
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H1InvalidRequestCL"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"content-length"
,
""
),
},
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
400
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestS3H2ConnectFailure
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
,
"--http2-bridge"
},
t
,
noopHandler
)
defer
st
.
Close
()
// simulate backend connect attempt failure
st
.
ts
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H2ConnectFailure"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
503
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
integration-tests/nghttpx_spdy_test.go
0 → 100644
View file @
990f9ed4
package
nghttp2
import
(
"github.com/bradfitz/http2/hpack"
"golang.org/x/net/spdy"
"net/http"
"testing"
)
func
TestS3H1PlainGET
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H1PlainGET"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
200
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
func
TestS3H1BadRequestCL
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
},
t
,
noopHandler
)
defer
st
.
Close
()
// we set content-length: 1024, but the actual request body is
// 3 bytes.
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H1BadRequestCL"
,
method
:
"POST"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"content-length"
,
"1024"
),
},
body
:
[]
byte
(
"foo"
),
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
spdy
.
ProtocolError
if
got
:=
res
.
spdyRstErrCode
;
got
!=
want
{
t
.
Errorf
(
"res.spdyRstErrCode = %v; want %v"
,
got
,
want
)
}
}
func
TestS3H1MultipleRequestCL
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Errorf
(
"server should not forward bad request"
)
})
defer
st
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H1MultipleRequestCL"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"content-length"
,
"1"
),
pair
(
"content-length"
,
"2"
),
},
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
400
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestS3H1InvalidRequestCL
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Errorf
(
"server should not forward bad request"
)
})
defer
st
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H1InvalidRequestCL"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"content-length"
,
""
),
},
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
400
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestS3H2ConnectFailure
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
,
"--http2-bridge"
},
t
,
noopHandler
)
defer
st
.
Close
()
// simulate backend connect attempt failure
st
.
ts
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H2ConnectFailure"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
503
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
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