Merge pull request #2732 from lucas-clemente/github-actions-unit-tests

use GitHub Actions to run unit tests
This commit is contained in:
Marten Seemann
2020-09-03 09:06:01 +07:00
committed by GitHub
9 changed files with 61 additions and 62 deletions

42
.github/workflows/unit.yml vendored Normal file
View File

@@ -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/setup-go@v2.1.1
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 }}

View File

@@ -31,7 +31,3 @@ before_install:
script:
- .travis/script.sh
after_success:
- .travis/after_success.sh

View File

@@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -ex
if [ ${TESTMODE} == "unit" ]; then
cat `find . -name "*.coverprofile"` > coverage.txt
bash <(curl -s https://codecov.io/bash) -f coverage.txt
fi

View File

@@ -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

View File

@@ -1,34 +0,0 @@
version: "{build}"
os: Windows Server 2012 R2
environment:
GOPATH: c:\gopath
CGO_ENABLED: 0
TIMESCALE_FACTOR: 40
matrix:
- GOARCH: 386
- GOARCH: amd64
clone_folder: c:\gopath\src\github.com\lucas-clemente\quic-go
install:
- rmdir c:\go /s /q
- appveyor-retry appveyor DownloadFile https://storage.googleapis.com/golang/go1.14.windows-amd64.zip
- 7z x go1.14.windows-amd64.zip -y -oC:\ > NUL
- set PATH=%PATH%;%GOPATH%\bin\windows_%GOARCH%;%GOPATH%\bin
- set GO111MODULE=on
- echo %PATH%
- echo %GOPATH%
- appveyor-retry go get github.com/onsi/ginkgo/ginkgo
- appveyor-retry go get github.com/onsi/gomega
- go version
- go env
build_script:
- ginkgo -r -v -randomizeAllSpecs -randomizeSuites -trace -skipPackage benchmark,integrationtests
- ginkgo -randomizeAllSpecs -randomizeSuites -trace benchmark -- -size=10
test: off
deploy: off

View File

@@ -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

View File

@@ -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
}

View File

@@ -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) {
@@ -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 {

View File

@@ -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() {
@@ -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())
})
})