Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add tests for reliable service under packet loss #63

Merged
merged 103 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
91057af
implementation of reliable transport
ainghazal Jan 24, 2024
aebf87e
rename & reordering
ainghazal Jan 24, 2024
b420eb1
wip
ainghazal Jan 24, 2024
add18bd
remove command, separate pr
ainghazal Jan 24, 2024
2c9761f
add command to get handshake logs
ainghazal Jan 24, 2024
51e2d34
remove unused code
ainghazal Jan 24, 2024
c3cb64d
add sender logging
ainghazal Jan 24, 2024
c85b9f3
add precision time logging in the text handler
ainghazal Jan 24, 2024
ba650b8
clearer logging
ainghazal Jan 24, 2024
0525989
unify packet logging
ainghazal Jan 24, 2024
9e5b744
checkpoint: improve logging, hack client hello ack to get moving
ainghazal Jan 25, 2024
f34af5c
checkpoint
ainghazal Jan 25, 2024
ff1ec51
checkpoint
ainghazal Jan 25, 2024
06d6c37
x
ainghazal Jan 25, 2024
bfd4380
testing
ainghazal Jan 25, 2024
44c6f9b
pass option to do just the handshake and no routes
ainghazal Jan 25, 2024
0e074d1
defend if data before keys
ainghazal Jan 25, 2024
2c6c941
improve comment
ainghazal Jan 29, 2024
b512ad9
comment on newHardResetPacket
ainghazal Jan 29, 2024
690762e
comments
ainghazal Jan 29, 2024
675fd8f
add elapsed time for benchmarking
ainghazal Jan 29, 2024
5b4d2eb
log
ainghazal Jan 29, 2024
8c5816c
add doc.go
ainghazal Jan 29, 2024
0c37284
x
ainghazal Jan 29, 2024
2fb6a3c
remove unused code
ainghazal Jan 29, 2024
80adb95
move comment location
ainghazal Jan 29, 2024
ba94049
x
ainghazal Jan 29, 2024
c941f02
remove commented code
ainghazal Jan 29, 2024
1bc2361
add link in docs
ainghazal Jan 29, 2024
20f89e2
rename in test
ainghazal Jan 29, 2024
9f751fb
remove binary
ainghazal Jan 29, 2024
f30db74
revert Makefile
ainghazal Jan 29, 2024
582ef20
Update internal/packetmuxer/service.go
ainghazal Jan 30, 2024
dcdffec
Update internal/reliabletransport/doc.go
ainghazal Jan 30, 2024
286b136
rename
ainghazal Jan 30, 2024
1fbbee5
apply suggestion
ainghazal Jan 30, 2024
2a15f2d
apply suggestions
ainghazal Jan 30, 2024
09fcc51
terminology
ainghazal Jan 30, 2024
e50e410
fix docs
ainghazal Jan 30, 2024
2095cab
inflight does not need to implement sort
ainghazal Jan 30, 2024
7009ffb
implement set for ack queue
ainghazal Jan 30, 2024
32a83e0
add tests for pending acks + evict after ack
ainghazal Jan 30, 2024
a814e13
test next packet ids to ack
ainghazal Jan 30, 2024
c1747c5
test ack empties
ainghazal Jan 30, 2024
9aaa7f1
remove tlssession logging from this pr, separated in a different one
ainghazal Jan 30, 2024
cc4f35f
note
ainghazal Jan 30, 2024
bddbfe4
x
ainghazal Jan 31, 2024
9171beb
Merge branch 'main' into refactor-reliable-impl
ainghazal Jan 31, 2024
037e6d1
test for inflightSequence
ainghazal Jan 31, 2024
5fcc0c6
fix tests for receiver
ainghazal Jan 31, 2024
60cf8ac
more coverage
ainghazal Jan 31, 2024
ae27c8f
x
ainghazal Jan 31, 2024
b1b0904
tests for next wakeup
ainghazal Jan 31, 2024
a701b83
tests for service initialization
ainghazal Jan 31, 2024
8071942
add more unit tests
ainghazal Jan 31, 2024
8547daf
first naive reordering test
ainghazal Feb 1, 2024
d07895c
going for a walk outside
ainghazal Feb 1, 2024
c5718ad
debug: wtf is going on
ainghazal Feb 1, 2024
b18c3ee
fix bug in sender that breaks loop
ainghazal Feb 1, 2024
a6cece1
remove debug lines
ainghazal Feb 1, 2024
5a961eb
cleanup test a bit
ainghazal Feb 1, 2024
6abd35d
add vpntest module
ainghazal Feb 2, 2024
bf7b83b
cosmetic changes
ainghazal Feb 2, 2024
39bc222
test packetio
ainghazal Feb 2, 2024
0bcb8de
parse acks
ainghazal Feb 2, 2024
d85275c
wip testing acks
ainghazal Feb 2, 2024
31abc06
ack testing utils
ainghazal Feb 2, 2024
7b92e6c
wip: ack duplicates compare set
ainghazal Feb 2, 2024
66a82dc
Merge branch 'main' into reliable-service-tests
ainghazal Feb 2, 2024
6bdc2d5
run the new tests in internal too
ainghazal Feb 2, 2024
80e8e50
x
ainghazal Feb 2, 2024
2a8632b
Merge branch 'main' into reliable-service-tests
ainghazal Feb 2, 2024
c84ad65
return if ack error
ainghazal Feb 2, 2024
cf17b41
add targets for testing internal path
ainghazal Feb 2, 2024
cd00bda
relax coverage threshold for now
ainghazal Feb 2, 2024
893f4e0
coverage for refactor
ainghazal Feb 2, 2024
7dba3b7
igore coverage output
ainghazal Feb 2, 2024
b902a49
remove extra comment
ainghazal Feb 2, 2024
ebdf71a
add relay with loss
ainghazal Feb 5, 2024
2ae804e
add tests for packet loss
ainghazal Feb 6, 2024
cbbdf40
reorganize code
ainghazal Feb 6, 2024
4cf6879
add package doc.go
ainghazal Feb 6, 2024
b49e26d
test echoserver
ainghazal Feb 6, 2024
d3431bd
tests for writesequencewithFixedPayload
ainghazal Feb 6, 2024
dd0b698
test for witness log
ainghazal Feb 6, 2024
7661d74
add test for expanded sequence
ainghazal Feb 6, 2024
3406791
update diagrams in tests
ainghazal Feb 7, 2024
2eb96cb
bump actions version, node12 is deprecated
ainghazal Feb 7, 2024
5edbff3
update setup-go to v5
ainghazal Feb 7, 2024
04e896d
Update internal/vpntest/packetio.go
ainghazal Feb 7, 2024
9fc8050
Merge branch 'main' into reliable-service-tests-loss
ainghazal Feb 7, 2024
49fdfc1
fix merge
ainghazal Feb 7, 2024
a8e6959
revert from main
ainghazal Feb 7, 2024
f76b2bc
remove commented out code
ainghazal Feb 7, 2024
6f83914
complete doc strings
ainghazal Feb 7, 2024
866d326
add a linter step to make reviews more fun
ainghazal Feb 7, 2024
d70fac8
x
ainghazal Feb 7, 2024
55492eb
set verbosity conditined on verbose tests
ainghazal Feb 7, 2024
4fde4d3
style
ainghazal Feb 7, 2024
55f8f1d
Update internal/reliabletransport/reliable_loss_test.go
ainghazal Feb 8, 2024
eaab530
Update internal/vpntest/packetio.go
ainghazal Feb 8, 2024
87eb468
Update internal/vpntest/packetio_test.go
ainghazal Feb 8, 2024
4b8b5c5
fix spacing
ainghazal Feb 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions .github/workflows/build-refactor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,30 @@ jobs:
short-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Run short tests
run: go test --short -cover ./internal/...

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint with revive action, from pre-built image
uses: docker://morphy/revive-action:v2
with:
path: "internal/..."

gosec:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run Gosec security scanner
uses: securego/gosec@master
with:
Expand All @@ -36,9 +45,9 @@ jobs:
coverage-threshold:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Ensure coverage threshold
Expand All @@ -47,9 +56,9 @@ jobs:
integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: run integration tests
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,19 @@ netns-shell:
sudo ip netns exec protected sudo -u `whoami` -i

.PHONY: lint
lint: go-fmt go-vet go-sec
lint: go-fmt go-vet go-sec go-revive

go-fmt:
gofmt -s -l .

go-vet:
go vet ./...
go vet internal/...

go-sec:
gosec ./...
gosec internal/...

go-revive:
revive internal/...

clean:
@rm -f coverage.out
4 changes: 2 additions & 2 deletions internal/reliabletransport/packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func newInFlightPacket(p *model.Packet) *inFlightPacket {

// ACKForHigherPacket increments the number of acks received for a higher pid than this packet. This will influence the fast rexmit selection algorithm.
func (p *inFlightPacket) ACKForHigherPacket() {
p.higherACKs += 1
p.higherACKs++
}

func (p *inFlightPacket) ScheduleForRetransmission(t time.Time) {
p.retries += 1
p.retries++
p.deadline = t.Add(p.backoff())
}

Expand Down
2 changes: 1 addition & 1 deletion internal/reliabletransport/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *reliableReceiver) NextIncomingSequence() incomingSequence {
for i, p := range r.incomingPackets {
if p.ID-last == 1 {
ready = append(ready, p)
last += 1
last++
} else if p.ID > last {
// here we broke sequentiality, but we want
// to drop anything that is below lastConsumed
Expand Down
8 changes: 6 additions & 2 deletions internal/reliabletransport/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ func Test_newReliableReceiver(t *testing.T) {
}

func Test_reliableQueue_MaybeInsertIncoming(t *testing.T) {
log.SetLevel(log.DebugLevel)
if testing.Verbose() {
log.SetLevel(log.DebugLevel)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


type fields struct {
incomingPackets incomingSequence
Expand Down Expand Up @@ -91,7 +93,9 @@ func Test_reliableQueue_MaybeInsertIncoming(t *testing.T) {
}

func Test_reliableQueue_NextIncomingSequence(t *testing.T) {
log.SetLevel(log.DebugLevel)
if testing.Verbose() {
log.SetLevel(log.DebugLevel)
}

type fields struct {
lastConsumed model.PacketID
Expand Down
34 changes: 15 additions & 19 deletions internal/reliabletransport/reliable_ack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@ import (
)

// test that everything that is received from below is eventually ACKed to the sender.
/*

┌────┐id ┌────┐
│sndr│◄──┤rcvr│
└─┬──┘ └──▲─┘
│ │
│ │
│ │
▼ send
ack
*/
func TestReliable_ACK(t *testing.T) {

log.SetLevel(log.DebugLevel)
if testing.Verbose() {
log.SetLevel(log.DebugLevel)
}

type args struct {
inputSequence []string
Expand Down Expand Up @@ -91,22 +103,6 @@ func TestReliable_ACK(t *testing.T) {
wantacks: 5,
},
},
/*
{
name: "a burst of packets",
args: args{
inputSequence: []string{
"[5] CONTROL_V1 +1ms",
"[1] CONTROL_V1 +1ms",
"[3] CONTROL_V1 +1ms",
"[2] CONTROL_V1 +1ms",
"[4] CONTROL_V1 +1ms",
},
start: 1,
wantacks: 5,
},
},
*/
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -148,7 +144,7 @@ func TestReliable_ACK(t *testing.T) {
reader := vpntest.NewPacketReader(dataOut)
witness := vpntest.NewWitness(reader)

if ok := witness.VerifyNumberOfACKs(tt.args.start, tt.args.wantacks, t0); !ok {
if ok := witness.VerifyNumberOfACKs(tt.args.wantacks, t0); !ok {
got := len(witness.Log().ACKs())
t.Errorf("TestACK: got = %v, want %v", got, tt.args.wantacks)
}
Expand Down
Loading
Loading