Skip to content

Commit

Permalink
cleanup: mark more integration tests as !short mode (#755)
Browse files Browse the repository at this point in the history
The objective is to make PR checks run much faster.

See ooni/probe#2113 for context.

Regarding netxlite's tests:

Checking for every commit on master or on a release branch is
good enough and makes pull requests faster than one minute since
netxlite for windows is now 1m slower than coverage.

We're losing some coverage but coverage from integration tests
is not so good anyway, so I'm not super sad about this loss.
  • Loading branch information
bassosimone authored May 24, 2022
1 parent 6924d1a commit d922bd9
Show file tree
Hide file tree
Showing 28 changed files with 143 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/netxlite.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# netxlite runs unit and integration tests on our fundamental net library
name: netxlite
on:
pull_request:
push:
branches:
- "master"
- "release/**"
jobs:
test_netxlite_package:
runs-on: "${{ matrix.os }}"
Expand Down
3 changes: 3 additions & 0 deletions cmd/ooniprobe/internal/nettests/nettests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func TestCreateContext(t *testing.T) {
}

func TestRun(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
probe := newOONIProbe(t)
sess, err := probe.NewSession(context.Background(), model.RunTypeManual)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions internal/cmd/apitool/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,25 @@ func init() {
}

func TestCheck(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
*mode = "check"
main()
}

func TestRaw(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
*mode = "raw"
main()
}

func TestMeta(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
*mode = "meta"
main()
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/jafar/badproxy/badproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestListenError(t *testing.T) {
}
}

func TestStarTLS(t *testing.T) {
func TestStartTLS(t *testing.T) {
expected := errors.New("mocked error")

t.Run("when we cannot create a new authority", func(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions internal/cmd/jafar/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func ensureWeStartOverWithIPTables() {
}

func TestNoCommand(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
if runtime.GOOS != "linux" {
t.Skip("skip test on non Linux systems")
}
Expand All @@ -30,6 +33,9 @@ func TestNoCommand(t *testing.T) {
}

func TestWithCommand(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
if runtime.GOOS != "linux" {
t.Skip("skip test on non Linux systems")
}
Expand All @@ -54,6 +60,7 @@ func TestMustx(t *testing.T) {
t.Fatal("should not happen")
}
})

t.Run("with non-exit-code error", func(t *testing.T) {
var (
called int
Expand All @@ -70,6 +77,7 @@ func TestMustx(t *testing.T) {
t.Fatal("unexpected exitcode value")
}
})

t.Run("with exit-code error", func(t *testing.T) {
var (
called int
Expand Down
3 changes: 3 additions & 0 deletions internal/cmd/jafar/resolver/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func TestRedirect(t *testing.T) {
}

func TestIgnore(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
server := newresolver(t, nil, nil, []string{"ooni.nu"})
iotimeout := "i/o timeout"
checkrequest(t, server, "hkgmetadb.ooni.nu", "hijacked", &iotimeout)
Expand Down
3 changes: 3 additions & 0 deletions internal/cmd/oohelper/internal/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func TestOOClientDoWithInvalidTargetURL(t *testing.T) {
}

func TestOOClientDoWithResolverFailure(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
Expand Down
3 changes: 3 additions & 0 deletions internal/cmd/oohelper/oohelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package main
import "testing"

func TestSmoke(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
*target = "http://www.example.com"
main()
}
9 changes: 9 additions & 0 deletions internal/cmd/oonireport/oonireport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func TestReadLines(t *testing.T) {
}

func TestNewSessionAndSubmitter(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
ctx := context.Background()
sess := newSession(ctx)
if sess == nil {
Expand Down Expand Up @@ -57,6 +60,9 @@ func TestMainMissingFile(t *testing.T) {
}

func TestMainEmptyFile(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
defer func() {
var s interface{}
if s = recover(); s != nil {
Expand All @@ -67,6 +73,9 @@ func TestMainEmptyFile(t *testing.T) {
}

func TestSubmitAllFails(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
ctx := context.Background()
sess := newSession(ctx)
subm := newSubmitter(sess, ctx)
Expand Down
3 changes: 3 additions & 0 deletions internal/engine/experiment/hirl/hirl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func TestNewExperimentMeasurer(t *testing.T) {
}

func TestSuccess(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
measurer := hirl.NewExperimentMeasurer(hirl.Config{})
ctx := context.Background()
sess := &mockable.Session{
Expand Down
3 changes: 3 additions & 0 deletions internal/engine/experiment/ndt7/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ func (r *invalidJSONReader) Read(p []byte) (int, error) {
}

func TestDownloadOnJSONLoop(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
mgr := newDownloadManager(
&mockableConnMock{
NextReaderMsgType: websocket.TextMessage,
Expand Down
3 changes: 3 additions & 0 deletions internal/engine/experiment/ndt7/ndt7_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ func TestFailUpload(t *testing.T) {
}

func TestDownloadJSONUnmarshalFail(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
measurer := NewExperimentMeasurer(Config{noUpload: true}).(*Measurer)
var seenError bool
expected := errors.New("expected error")
Expand Down
3 changes: 3 additions & 0 deletions internal/engine/experiment/ndt7/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func TestUploadWritePreparedMessageSubsequentFailure(t *testing.T) {
}

func TestUploadLoop(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
mgr := newUploadManager(
&mockableConnMock{},
defaultCallbackPerformance,
Expand Down
15 changes: 15 additions & 0 deletions internal/engine/experiment/quicping/quicping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func TestInvalidHost(t *testing.T) {
}

func TestURLInput(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
measurer := NewExperimentMeasurer(Config{
Repetitions: 1,
})
Expand All @@ -123,6 +126,9 @@ func TestURLInput(t *testing.T) {
}

func TestSuccess(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
measurer := NewExperimentMeasurer(Config{})
measurement := new(model.Measurement)
measurement.Input = model.MeasurementTarget("google.com")
Expand Down Expand Up @@ -201,6 +207,9 @@ func TestListenFails(t *testing.T) {
}

func TestWriteFails(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
expected := errors.New("expected")
measurer := NewExperimentMeasurer(Config{
networkLib: &FailStdLib{err: nil, readErr: nil, writeErr: expected},
Expand Down Expand Up @@ -229,6 +238,9 @@ func TestWriteFails(t *testing.T) {
}

func TestReadFails(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
expected := errors.New("expected")
measurer := NewExperimentMeasurer(Config{
networkLib: &FailStdLib{err: nil, readErr: expected, writeErr: nil},
Expand All @@ -254,6 +266,9 @@ func TestReadFails(t *testing.T) {
}

func TestNoResponse(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
measurer := NewExperimentMeasurer(Config{
Repetitions: 1,
})
Expand Down
6 changes: 6 additions & 0 deletions internal/engine/experiment/whatsapp/whatsapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func TestNewExperimentMeasurer(t *testing.T) {
}

func TestSuccess(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
measurer := whatsapp.NewExperimentMeasurer(whatsapp.Config{})
ctx := context.Background()
sess := &mockable.Session{MockableLogger: log.Log}
Expand Down Expand Up @@ -555,6 +558,9 @@ func TestTestKeysOnlyWebHTTPFailureTooManyURLs(t *testing.T) {
}

func TestWeConfigureWebChecksCorrectly(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
called := &atomicx.Int64{}
emptyConfig := urlgetter.Config{}
configWithFailOnHTTPError := urlgetter.Config{FailOnHTTPError: true}
Expand Down
3 changes: 3 additions & 0 deletions internal/engine/probeservices/bouncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
)

func TestGetTestHelpers(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
testhelpers, err := newclient().GetTestHelpers(context.Background())
if err != nil {
t.Fatal(err)
Expand Down
3 changes: 3 additions & 0 deletions internal/engine/probeservices/checkreportid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
)

func TestCheckReportIDWorkingAsIntended(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
client := probeservices.Client{
APIClientTemplate: httpx.APIClientTemplate{
BaseURL: "https://ams-pg.ooni.org/",
Expand Down
3 changes: 3 additions & 0 deletions internal/engine/probeservices/tor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
)

func TestFetchTorTargets(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
clnt := newclient()
if err := clnt.MaybeRegister(context.Background(), testorchestra.MetadataFixture()); err != nil {
t.Fatal(err)
Expand Down
3 changes: 3 additions & 0 deletions internal/netxlite/filtering/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
)

func TestDNSProxy(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
newProxyWithCache := func(action DNSAction, cache map[string][]string) (DNSListener, <-chan interface{}, error) {
p := &DNSProxy{
Cache: cache,
Expand Down
3 changes: 3 additions & 0 deletions internal/netxlite/filtering/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
)

func TestHTTPProxy(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
newproxy := func(action HTTPAction) (net.Listener, error) {
p := &HTTPProxy{
OnIncomingHost: func(host string) HTTPAction {
Expand Down
3 changes: 3 additions & 0 deletions internal/netxlite/filtering/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
)

func TestTLSProxy(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
newproxy := func(action TLSAction) (net.Listener, <-chan interface{}, error) {
p := &TLSProxy{
OnIncomingSNI: func(sni string) TLSAction {
Expand Down
3 changes: 3 additions & 0 deletions internal/netxlite/filtering/tproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ func TestTProxyOnIncomingHost(t *testing.T) {
}

func TestTProxyDial(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
t.Run("with drop SYN", func(t *testing.T) {
config := &TProxyConfig{
Endpoints: map[string]TProxyPolicy{
Expand Down
37 changes: 0 additions & 37 deletions internal/ooapi/example_test.go

This file was deleted.

Loading

0 comments on commit d922bd9

Please sign in to comment.