cleanup: mark more integration tests as !short mode (#755)

The objective is to make PR checks run much faster.

See https://github.com/ooni/probe/issues/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.
This commit is contained in:
Simone Basso 2022-05-24 21:01:15 +02:00 committed by GitHub
commit d922bd9afc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 143 additions and 70 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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,
})
@ -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")
@ -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},
@ -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},
@ -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,
})

View file

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

View file

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

View file

@ -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/",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,37 +0,0 @@
package ooapi_test
import (
"context"
"fmt"
"log"
"github.com/ooni/probe-cli/v3/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/ooapi"
"github.com/ooni/probe-cli/v3/internal/ooapi/apimodel"
)
func ExampleClient() {
clnt := &ooapi.Client{
KVStore: &kvstore.Memory{},
}
ctx := context.Background()
resp, err := clnt.CheckIn(ctx, &apimodel.CheckInRequest{
Charging: false,
OnWiFi: false,
Platform: "linux",
ProbeASN: "AS30722",
ProbeCC: "IT",
RunType: model.RunTypeTimed,
SoftwareName: "miniooni",
SoftwareVersion: "0.1.0-dev",
WebConnectivity: apimodel.CheckInRequestWebConnectivity{
CategoryCodes: []string{"NEWS"},
},
})
fmt.Printf("%+v\n", err)
// Output: <nil>
if resp == nil {
log.Fatal("expected non-nil response")
}
}