Skip to content

Commit

Permalink
ci: misc test-related fixes (open-policy-agent#4549)
Browse files Browse the repository at this point in the history
* topdown: fix TestRego: run for all go versions, excluding the x509 error

That error has a different message on go1.16.

The previous attempt to exclude them from running caused _all tests_
to not be run.

* topdown_test/TestTopDownQueryCancellationEvery: up wait time for macos flakey tests

We've often seen this fail with "0 notes". Waiting for 10x the time
we previous waited for still seems to do the trick but should
hopefully remove the amount of failures we see in CE because of
slow macos runners.

* ci: don't run wasm build again in compat builds

The build is docker-based, and doesn't differ at all if run from a
different version of golang. So instead of re-building it in the
separate matrix jobs, we'll use the artifacts downloaded from the
artifact build job.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
  • Loading branch information
srenatus committed Apr 5, 2022
1 parent e9d3828 commit a940cb6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pull-request.yaml
Expand Up @@ -298,7 +298,12 @@ jobs:
with:
go-version: ${{ matrix.version }}
- run: make build
env:
DOCKER_RUNNING: 0
- run: make go-test
env:
DOCKER_RUNNING: 0


# Run PR metadata against Rego policies
rego-check-pr:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -29,7 +29,7 @@ endif

GOLANGCI_LINT_VERSION := v1.43.0

DOCKER_RUNNING := $(shell docker ps >/dev/null 2>&1 && echo 1 || echo 0)
DOCKER_RUNNING ?= $(shell docker ps >/dev/null 2>&1 && echo 1 || echo 0)

# We use root because the windows build, invoked through the ci-go-build-windows
# target, installs the gcc mingw32 cross-compiler.
Expand Down
27 changes: 20 additions & 7 deletions topdown/exported_test.go
Expand Up @@ -2,19 +2,13 @@
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.

// NOTE(sr): x509-related errors that we assert in the exported tests looked different
// before go1.17. Since they are still (non-strict) errors in both cases, we'll skip
// running the exported tests on go1.16.
// This can be removed when we drop support for go 1.16.
//go:build !go1.16
// +build !go1.16

package topdown

import (
"context"
"fmt"
"os"
"runtime"
"sort"
"strings"
"testing"
Expand All @@ -25,8 +19,27 @@ import (
"github.com/open-policy-agent/opa/test/cases"
)

var x508Exceptions = []string{
"cryptox509parsecertificates/invalid DER or PEM data, b64",
}

func isException(note string) bool {
for _, exc := range x508Exceptions {
if note == exc {
return true
}
}
return false
}

func TestRego(t *testing.T) {
for _, tc := range cases.MustLoad("../test/cases/testdata").Sorted().Cases {
if strings.HasPrefix(runtime.Version(), "go1.16") && isException(tc.Note) {
t.Run(tc.Note, func(t *testing.T) {
t.Skip("skipped for go1.16, x509 errors differ")
})
continue
}
t.Run(tc.Note, func(t *testing.T) {
testRun(t, tc)
})
Expand Down
2 changes: 1 addition & 1 deletion topdown/topdown_test.go
Expand Up @@ -295,7 +295,7 @@ func TestTopDownQueryCancellationEvery(t *testing.T) {

done := make(chan struct{})
go func() {
time.Sleep(time.Millisecond * 50)
time.Sleep(time.Millisecond * 500)
cancel.Cancel()
close(done)
}()
Expand Down

0 comments on commit a940cb6

Please sign in to comment.