Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishapi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishapi
Commits
b70e72db
Commit
b70e72db
authored
Aug 21, 2018
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the e2e test for Log.Read() robuster.
parent
7fd59f69
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
37 deletions
+21
-37
e2e_test.go
pkg/log/e2e_test.go
+21
-37
No files found.
pkg/log/e2e_test.go
View file @
b70e72db
...
...
@@ -140,8 +140,8 @@ type expTxGrp struct {
txGrp
[]
expTxLen
}
var
expDefaultRead
=
[
]
expTxGrp
{
{
var
expDefaultRead
=
map
[
TxType
]
expTxGrp
{
BeReq
:
{
expTx
:
1
,
txGrp
:
[]
expTxLen
{{
expRecs
:
undefLen
,
...
...
@@ -154,7 +154,7 @@ var expDefaultRead = []expTxGrp{
recs
:
nil
,
}}},
},
{
Req
:
{
expTx
:
1
,
txGrp
:
[]
expTxLen
{{
expRecs
:
undefLen
,
...
...
@@ -167,7 +167,7 @@ var expDefaultRead = []expTxGrp{
recs
:
nil
,
}}},
},
{
Sess
:
{
expTx
:
1
,
txGrp
:
[]
expTxLen
{{
expRecs
:
5
,
...
...
@@ -299,17 +299,6 @@ func checkTxGrp(t *testing.T, txGrp []Tx, expTxGrp expTxGrp) {
}
}
func
checkTxGrps
(
t
*
testing
.
T
,
txGrps
[][]
Tx
,
expTxGrps
[]
expTxGrp
)
{
if
len
(
txGrps
)
!=
len
(
expTxGrps
)
{
t
.
Fatalf
(
"number of tx groups got=%v want=%v"
,
len
(
txGrps
),
len
(
expTxGrps
))
return
}
for
i
,
txGrp
:=
range
txGrps
{
checkTxGrp
(
t
,
txGrp
,
expTxGrps
[
i
])
}
}
func
checkBereq
(
t
*
testing
.
T
,
tx
Tx
,
req
http
.
Request
)
{
if
tx
.
Type
!=
BeReq
{
t
.
Fatalf
(
"checkBereq() tx.Type want=BeReq got=%s"
,
tx
.
Type
)
...
...
@@ -432,26 +421,30 @@ func TestE2EDefaultRead(t *testing.T) {
t
.
Fatal
(
"Attach(default):"
,
err
)
}
statusChan
:=
make
(
chan
Status
)
txChan
:=
make
(
chan
[]
Tx
,
100
)
var
status
Status
var
txGrps
[][]
Tx
rdHndlr
:=
func
(
txGrp
[]
Tx
,
rdstatus
Status
)
bool
{
switch
rdstatus
{
case
More
:
txChan
<-
txGrp
txGrps
=
append
(
txGrps
,
txGrp
)
if
len
(
txGrps
)
==
3
{
return
false
}
return
true
default
:
status
Chan
<-
rdstatus
status
=
rdstatus
return
false
}
}
stopChan
:=
make
(
chan
bool
)
readFailed
:=
false
go
func
()
{
err
:=
l
.
Read
(
rdHndlr
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
"Read(): "
+
err
.
Error
())
readFailed
=
true
return
}
stopChan
<-
true
}()
client
:=
&
http
.
Client
{}
...
...
@@ -465,29 +458,20 @@ func TestE2EDefaultRead(t *testing.T) {
t
.
Fatal
(
"/uncacheable Response"
,
err
)
}
var
txGrps
[][]
Tx
TX
:
for
{
select
{
case
status
:=
<-
statusChan
:
t
.
Fatal
(
"status"
,
status
)
<-
stopChan
if
readFailed
{
return
case
txGrp
:=
<-
txChan
:
txGrps
=
append
(
txGrps
,
txGrp
)
if
len
(
txGrps
)
==
3
{
break
TX
}
continue
}
if
status
!=
Stopped
{
t
.
Errorf
(
"End read status want=%v got=%v"
,
Stopped
,
status
)
}
if
readFailed
{
return
if
len
(
txGrps
)
!=
3
{
t
.
Errorf
(
"number of tx groups want=3 got=%v"
,
len
(
txGrps
))
}
checkTxGrps
(
t
,
txGrps
,
expDefaultRead
)
for
_
,
txGrp
:=
range
txGrps
{
tx
:=
txGrp
[
0
]
checkTxGrp
(
t
,
txGrp
,
expDefaultRead
[
tx
.
Type
])
if
tx
.
Type
==
BeReq
{
checkBereq
(
t
,
tx
,
*
req
)
}
...
...
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