Skip to content

Commit

Permalink
ci: Add windows test runner (sourcenetwork#2033)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Resolves sourcenetwork#2032 

## Description

Adds a windows test run to our test matrix.
  • Loading branch information
AndrewSisley authored Nov 20, 2023
1 parent 31dbbcc commit fae852d
Show file tree
Hide file tree
Showing 16 changed files with 272 additions and 62 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/test-and-upload-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
name: Run tests matrix job

strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
client-type: [go, http, cli]
Expand All @@ -45,9 +46,19 @@ jobs:
database-type: badger-memory
mutation-type: collection-save
detect-changes: false
- os: windows-latest
client-type: go
database-type: badger-memory
mutation-type: collection-save
detect-changes: false

runs-on: ${{ matrix.os }}

# We run all runners via the bash shell to provide us with a consistent set of env variables and commands
defaults:
run:
shell: bash

env:
CGO_ENABLED: 1
DEFRA_CLIENT_GO: ${{ matrix.client-type == 'go' }}
Expand Down
5 changes: 5 additions & 0 deletions config/configfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"bytes"
"os"
"path/filepath"
"runtime"
"testing"
"text/template"

Expand Down Expand Up @@ -61,6 +62,10 @@ func TestWritesConfigFileErroneousPath(t *testing.T) {
}

func TestReadConfigFileForLogger(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skipf("Test is not supported on windows as it leaks resources, see https://github.com/sourcenetwork/defradb/issues/2057")
}

cfg := DefaultConfig()
tmpdir := t.TempDir()
cfg.Rootdir = tmpdir
Expand Down
68 changes: 68 additions & 0 deletions datastore/badger/v4/datastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func TestNewDatastoreWithOptions(t *testing.T) {

s, err := NewDatastore(dir, &opt)
require.NoError(t, err)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

s.Put(ctx, testKey1, testValue1)
s.Put(ctx, testKey2, testValue2)
Expand All @@ -68,6 +72,10 @@ func TestNewDatastoreWithOptions(t *testing.T) {
func TestNewBatch(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

b, err := s.Batch(ctx)
require.NoError(t, err)
Expand All @@ -77,6 +85,10 @@ func TestNewBatch(t *testing.T) {
func TestBatchOperations(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

b, err := s.Batch(ctx)
require.NoError(t, err)
Expand Down Expand Up @@ -154,6 +166,10 @@ func TestBatchCommitWithStoreClosed(t *testing.T) {
func TestBatchConsecutiveCommit(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

b, err := s.Batch(ctx)
require.NoError(t, err)
Expand All @@ -168,6 +184,10 @@ func TestBatchConsecutiveCommit(t *testing.T) {
func TestCollectGarbage(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

err := s.CollectGarbage(ctx)
require.NoError(t, err)
Expand Down Expand Up @@ -206,6 +226,10 @@ func TestConsecutiveClose(t *testing.T) {
func TestGetOperation(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

resp, err := s.Get(ctx, testKey1)
require.NoError(t, err)
Expand All @@ -225,6 +249,10 @@ func TestGetOperationWithStoreClosed(t *testing.T) {
func TestGetOperationNotFound(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

_, err := s.Get(ctx, testKey3)
require.ErrorIs(t, err, ds.ErrNotFound)
Expand All @@ -233,6 +261,10 @@ func TestGetOperationNotFound(t *testing.T) {
func TestDeleteOperation(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

err := s.Delete(ctx, testKey1)
require.NoError(t, err)
Expand All @@ -244,6 +276,10 @@ func TestDeleteOperation(t *testing.T) {
func TestDeleteOperation2(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

err := s.Put(ctx, testKey1, testValue1)
require.NoError(t, err)
Expand All @@ -269,6 +305,10 @@ func TestDeleteOperationWithStoreClosed(t *testing.T) {
func TestGetSizeOperation(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

resp, err := s.GetSize(ctx, testKey1)
require.NoError(t, err)
Expand All @@ -278,6 +318,10 @@ func TestGetSizeOperation(t *testing.T) {
func TestGetSizeOperationNotFound(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

_, err := s.GetSize(ctx, testKey3)
require.ErrorIs(t, err, ds.ErrNotFound)
Expand All @@ -297,6 +341,10 @@ func TestGetSizeOperationWithStoreClosed(t *testing.T) {
func TestHasOperation(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

resp, err := s.Has(ctx, testKey1)
require.NoError(t, err)
Expand All @@ -306,6 +354,10 @@ func TestHasOperation(t *testing.T) {
func TestHasOperationNotFound(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

resp, err := s.Has(ctx, testKey3)
require.NoError(t, err)
Expand All @@ -326,6 +378,10 @@ func TestHasOperationWithStoreClosed(t *testing.T) {
func TestPutOperation(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

err := s.Put(ctx, testKey3, testValue3)
require.NoError(t, err)
Expand All @@ -349,6 +405,10 @@ func TestPutOperationWithStoreClosed(t *testing.T) {
func TestQueryOperation(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

results, err := s.Query(ctx, dsq.Query{
Limit: 1,
Expand Down Expand Up @@ -379,6 +439,10 @@ func TestQueryOperationWithStoreClosed(t *testing.T) {
func TestDiskUsage(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()

size, err := s.DiskUsage(ctx)
require.NoError(t, err)
Expand All @@ -399,6 +463,10 @@ func TestDiskUsageWithStoreClosed(t *testing.T) {
func TestSync(t *testing.T) {
ctx := context.Background()
s := newLoadedDatastore(ctx, t)
defer func() {
err := s.Close()
require.NoError(t, err)
}()
err := s.Sync(ctx, testKey1)
require.NoError(t, err)
}
Expand Down
4 changes: 3 additions & 1 deletion datastore/memory/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ func TestClearOldFlightTransactions(t *testing.T) {
s.inFlightTxn.Set(dsTxn{
dsVersion: s.getVersion(),
txnVersion: s.getVersion() + 1,
expiresAt: time.Now(),
// Ensure expiresAt is before the value returned from the later call in `clearOldInFlightTxn`,
// in windows in particular it seems that the two `time.Now` calls can return the same value
expiresAt: time.Now().Add(-1 * time.Minute),
})

require.Equal(t, 1, s.inFlightTxn.Len())
Expand Down
Loading

0 comments on commit fae852d

Please sign in to comment.