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
parent 6924d1ad81
commit d922bd9afc
28 changed files with 143 additions and 70 deletions
+18 -27
View File
@@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"runtime"
"strings"
@@ -33,9 +32,6 @@ func NewSessionForTesting() (*oonimkall.Session, error) {
}
func TestNewSessionWithInvalidStateDir(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := oonimkall.NewSession(&oonimkall.SessionConfig{
StateDir: "",
})
@@ -47,29 +43,6 @@ func TestNewSessionWithInvalidStateDir(t *testing.T) {
}
}
func TestMaybeUpdateResourcesWithCancelledContext(t *testing.T) {
// Note that MaybeUpdateResources is now a deprecated stub that
// does nothing. We will remove it when we bump major.
dir, err := ioutil.TempDir("", "xx")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
sess, err := NewSessionForTestingWithAssetsDir(dir)
if err != nil {
t.Fatal(err)
}
ctx := sess.NewContext()
ctx.Cancel() // cause immediate failure
err = sess.MaybeUpdateResources(ctx)
// Explanation: we embed resources. We should change the API
// and remove the context. Until we do that, let us just assert
// that we have embedding and the context does not matter.
if err != nil {
t.Fatal(err)
}
}
func ReduceErrorForGeolocate(err error) error {
if err == nil {
return errors.New("we expected an error here")
@@ -250,6 +223,9 @@ func TestSubmitCancelContextAfterFirstSubmission(t *testing.T) {
}
func TestCheckInSuccess(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := NewSessionForTesting()
if err != nil {
t.Fatal(err)
@@ -298,6 +274,9 @@ func TestCheckInSuccess(t *testing.T) {
}
func TestCheckInLookupLocationFailure(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := NewSessionForTesting()
if err != nil {
t.Fatal(err)
@@ -325,6 +304,9 @@ func TestCheckInLookupLocationFailure(t *testing.T) {
}
func TestCheckInNewProbeServicesFailure(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := NewSessionForTesting()
if err != nil {
t.Fatal(err)
@@ -354,6 +336,9 @@ func TestCheckInNewProbeServicesFailure(t *testing.T) {
}
func TestCheckInCheckInFailure(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := NewSessionForTesting()
if err != nil {
t.Fatal(err)
@@ -383,6 +368,9 @@ func TestCheckInCheckInFailure(t *testing.T) {
}
func TestCheckInNoParams(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := NewSessionForTesting()
if err != nil {
t.Fatal(err)
@@ -441,6 +429,9 @@ func TestFetchURLListSuccess(t *testing.T) {
}
func TestFetchURLListWithCC(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := NewSessionForTesting()
if err != nil {
t.Fatal(err)
+15
View File
@@ -26,6 +26,9 @@ func TestClampTimeout(t *testing.T) {
}
func TestNewContextWithZeroTimeout(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
here := &atomicx.Int64{}
ctx, cancel := newContext(0)
defer cancel()
@@ -41,6 +44,9 @@ func TestNewContextWithZeroTimeout(t *testing.T) {
}
func TestNewContextWithNegativeTimeout(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
here := &atomicx.Int64{}
ctx, cancel := newContext(-1)
defer cancel()
@@ -56,6 +62,9 @@ func TestNewContextWithNegativeTimeout(t *testing.T) {
}
func TestNewContextWithHugeTimeout(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
here := &atomicx.Int64{}
ctx, cancel := newContext(maxTimeout + 1)
defer cancel()
@@ -71,6 +80,9 @@ func TestNewContextWithHugeTimeout(t *testing.T) {
}
func TestNewContextWithReasonableTimeout(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
here := &atomicx.Int64{}
ctx, cancel := newContext(1)
defer cancel()
@@ -86,6 +98,9 @@ func TestNewContextWithReasonableTimeout(t *testing.T) {
}
func TestNewContextWithArtificiallyLowMaxTimeout(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
here := &atomicx.Int64{}
const maxTimeout = 2
ctx, cancel := newContextEx(maxTimeout+1, maxTimeout)
+9
View File
@@ -14,6 +14,9 @@ type eventlike struct {
}
func TestStartTaskGood(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
task, err := StartTask(`{
"log_level": "DEBUG",
"name": "Example",
@@ -63,6 +66,9 @@ func TestStartTaskInvalidJSON(t *testing.T) {
}
func TestStartTaskCountBytesForExample(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
task, err := StartTask(`{
"name": "Example",
"options": {
@@ -142,6 +148,9 @@ func TestPrivacyAndScrubbing(t *testing.T) {
}
func TestNonblockWithFewEvents(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
// This test tests whether we won't block for a small
// number of events emitted by the task
task, err := StartTask(`{
+4 -4
View File
@@ -1,15 +1,15 @@
package oonimkall
//
// This file contains tests for the taskLogger type.
//
import (
"testing"
"github.com/ooni/probe-cli/v3/internal/model"
)
//
// This file contains tests for the taskLogger type.
//
func TestTaskLogger(t *testing.T) {
// debugMessage is the debug message we expect to see.
debugMessage := "debug message"
+3
View File
@@ -30,6 +30,9 @@ func TestMeasurementSubmissionFailure(t *testing.T) {
}
func TestTaskRunnerRun(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
// newRunnerForTesting is a factory for creating a new
// runner that wraps newRunner and also sets a specific