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

use GitHub Actions to run unit tests #2732

Merged
merged 2 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 42 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on: [push, pull_request]


jobs:
unit:
strategy:
matrix:
os: [ "ubuntu", "windows", "macos" ]
go: [ "1.14", "1.15" ]
runs-on: ${{ matrix.os }}-latest
name: Unit tests (${{ matrix.os}}, Go ${{ matrix.go }})
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}
- run: go version
- name: Install test tools
run: |
go get golang.org/x/tools/cmd/cover
go get github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega
- name: Install dependencies
run: go build
- name: Run tests
env:
TIMESCALE_FACTOR: 10
run: ginkgo -r -v -cover -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark
- name: Run tests with race detector
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
env:
TIMESCALE_FACTOR: 20
run: ginkgo -r -v -race -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark
- name: Gather coverage reports
if: ${{ matrix.os != 'windows' }} # TODO: figure out how to upload windows logs
run: cat `find . -name "*.coverprofile"` > coverage.txt
- name: Upload coverage to Codecov
if: ${{ matrix.os != 'windows' }} # TODO: figure out how to upload windows logs
uses: codecov/codecov-action@v1
with:
file: ./coverage.txt
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,3 @@ before_install:

script:
- .travis/script.sh


after_success:
- .travis/after_success.sh
8 changes: 0 additions & 8 deletions .travis/after_success.sh

This file was deleted.

7 changes: 1 addition & 6 deletions .travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
set -ex

if [ "${TESTMODE}" == "unit" ]; then
ginkgo -r -v -cover -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark
# run unit tests with the Go race detector
# The Go race detector only works on amd64.
if [ "${TRAVIS_GOARCH}" == 'amd64' ]; then
ginkgo -race -r -v -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark
fi
ginkgo -r -v -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark
fi

if [ "${TESTMODE}" == "integration" ]; then
Expand Down
34 changes: 0 additions & 34 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion internal/flowcontrol/base_flow_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ var _ = Describe("Base Flow controller", func() {

It("increases the window size if read so fast that the window would be consumed in less than 4 RTTs", func() {
bytesRead := controller.bytesRead
rtt := scaleDuration(20 * time.Millisecond)
rtt := scaleDuration(50 * time.Millisecond)
setRtt(rtt)
// consume more than 2/3 of the window...
dataRead := receiveWindowSize*2/3 + 1
Expand Down
8 changes: 4 additions & 4 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,10 @@ var _ = Describe("Server", func() {
<-acceptSession
atomic.AddUint32(&counter, 1)
sess := NewMockQuicSession(mockCtrl)
sess.EXPECT().handlePacket(gomock.Any())
sess.EXPECT().run()
sess.EXPECT().Context().Return(context.Background())
sess.EXPECT().HandshakeComplete().Return(context.Background())
sess.EXPECT().handlePacket(gomock.Any()).MaxTimes(1)
sess.EXPECT().run().MaxTimes(1)
sess.EXPECT().Context().Return(context.Background()).MaxTimes(1)
sess.EXPECT().HandshakeComplete().Return(context.Background()).MaxTimes(1)
return sess
}

Expand Down
14 changes: 10 additions & 4 deletions zero_rtt_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ type zeroRTTQueueEntry struct {
}

type zeroRTTQueue struct {
mutex sync.Mutex
queue map[string]*zeroRTTQueueEntry
mutex sync.Mutex
queue map[string]*zeroRTTQueueEntry
queueDuration time.Duration // so we can set it in tests
}

func newZeroRTTQueue() *zeroRTTQueue {
return &zeroRTTQueue{queue: make(map[string]*zeroRTTQueueEntry)}
return &zeroRTTQueue{
queue: make(map[string]*zeroRTTQueueEntry),
queueDuration: protocol.Max0RTTQueueingDuration,
}
}

func (h *zeroRTTQueue) Enqueue(connID protocol.ConnectionID, p *receivedPacket) {
Expand All @@ -30,7 +34,9 @@ func (h *zeroRTTQueue) Enqueue(connID protocol.ConnectionID, p *receivedPacket)
if len(h.queue) >= protocol.Max0RTTQueues {
return
}
h.queue[cid] = &zeroRTTQueueEntry{timer: time.AfterFunc(protocol.Max0RTTQueueingDuration, func() { h.deleteQueue(connID) })}
h.queue[cid] = &zeroRTTQueueEntry{timer: time.AfterFunc(h.queueDuration, func() {
h.deleteQueue(connID)
})}
}
entry := h.queue[cid]
if len(entry.packets) >= protocol.Max0RTTQueueLen {
Expand Down
4 changes: 3 additions & 1 deletion zero_rtt_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import (

var _ = Describe("0-RTT queue", func() {
var q *zeroRTTQueue
queueDuration := scaleDuration(20 * time.Millisecond)

BeforeEach(func() {
q = newZeroRTTQueue()
q.queueDuration = queueDuration
})

AfterEach(func() {
Expand Down Expand Up @@ -107,7 +109,7 @@ var _ = Describe("0-RTT queue", func() {
connID := protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}
p := &receivedPacket{data: []byte("foobar"), buffer: getPacketBuffer()}
q.Enqueue(connID, p)
time.Sleep(protocol.Max0RTTQueueingDuration * 3 / 2)
time.Sleep(queueDuration * 3 / 2)
Expect(q.Dequeue(connID)).To(BeNil())
})
})