diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e91f2b3b0..a2ac5dc3a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,7 +31,12 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: go tests + if: ${{ matrix.platform != 'windows-latest' }} run: go test -tags=baton_lambda_support -v -covermode=count -json ./... > test.json + - name: go tests + if: ${{ matrix.platform == 'windows-latest' }} + # Run tests with -short on Windows since its filesystem is very slow, causing CI to time out. + run: go test -tags=baton_lambda_support -short -v -covermode=count -json ./... > test.json - name: Print go test results if: always() run: cat test.json diff --git a/pkg/dotc1z/race_test.go b/pkg/dotc1z/race_test.go index 1733ea13e..f21b6c489 100644 --- a/pkg/dotc1z/race_test.go +++ b/pkg/dotc1z/race_test.go @@ -36,7 +36,7 @@ func TestWALCheckpointRace(t *testing.T) { // Number of iterations - increase for more thorough testing iterations := 100 - for i := 0; i < iterations; i++ { + for i := range iterations { t.Run(fmt.Sprintf("iteration_%d", i), func(t *testing.T) { testFilePath := filepath.Join(tmpDir, fmt.Sprintf("wal_race_%d.c1z", i)) @@ -49,7 +49,7 @@ func TestWALCheckpointRace(t *testing.T) { // Create multiple resource types to generate WAL activity resourceTypeIDs := make([]string, 50) - for j := 0; j < 50; j++ { + for j := range 50 { resourceTypeIDs[j] = fmt.Sprintf("resource-type-%d-%d", i, j) err = f.PutResourceTypes(ctx, v2.ResourceType_builder{ Id: resourceTypeIDs[j], @@ -59,7 +59,7 @@ func TestWALCheckpointRace(t *testing.T) { require.NoError(t, err) // Add resources for each type - for k := 0; k < 10; k++ { + for k := range 10 { err = f.PutResources(ctx, v2.Resource_builder{ Id: v2.ResourceId_builder{ ResourceType: resourceTypeIDs[j], @@ -97,7 +97,7 @@ func TestWALCheckpointRace(t *testing.T) { "resource type count mismatch on iteration %d: expected 50, got %d", i, stats["resource_types"]) // Verify each resource type and its resources - for j := 0; j < 50; j++ { + for j := range 50 { rtID := fmt.Sprintf("resource-type-%d-%d", i, j) count, ok := stats[rtID] require.True(t, ok, "resource type %s not found in stats on iteration %d", rtID, i) @@ -121,7 +121,7 @@ func TestC1ZIntegrity(t *testing.T) { ctx := context.Background() tmpDir := t.TempDir() - for i := 0; i < 50; i++ { + for i := range 50 { t.Run(fmt.Sprintf("iteration_%d", i), func(t *testing.T) { testFilePath := filepath.Join(tmpDir, fmt.Sprintf("integrity_%d.c1z", i)) @@ -134,13 +134,13 @@ func TestC1ZIntegrity(t *testing.T) { // Write random amount of data numTypes := 10 + (i % 20) - for j := 0; j < numTypes; j++ { + for j := range numTypes { rtID := fmt.Sprintf("rt-%d-%d", i, j) err = f.PutResourceTypes(ctx, v2.ResourceType_builder{Id: rtID}.Build()) require.NoError(t, err) numResources := 5 + (j % 15) - for k := 0; k < numResources; k++ { + for k := range numResources { err = f.PutResources(ctx, v2.Resource_builder{ Id: v2.ResourceId_builder{ ResourceType: rtID, diff --git a/pkg/sync/expand/expand_benchmark_test.go b/pkg/sync/expand/expand_benchmark_test.go index a650303bf..11644d284 100644 --- a/pkg/sync/expand/expand_benchmark_test.go +++ b/pkg/sync/expand/expand_benchmark_test.go @@ -169,8 +169,9 @@ func benchmarkExpand(b *testing.B, syncID string) { tmpFile, err := os.CreateTemp("", "bench-expand-*.c1z") require.NoError(b, err) tmpPath := tmpFile.Name() - tmpFile.Close() defer os.Remove(tmpPath) + err = tmpFile.Close() + require.NoError(b, err) // Copy original c1z to temp srcData, err := os.ReadFile(c1zPath) diff --git a/pkg/sync/expand/expand_correctness_test.go b/pkg/sync/expand/expand_correctness_test.go index f90c3d42b..347e709d9 100644 --- a/pkg/sync/expand/expand_correctness_test.go +++ b/pkg/sync/expand/expand_correctness_test.go @@ -12,6 +12,7 @@ import ( v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2" "github.com/conductorone/baton-sdk/pkg/dotc1z" + sdkLogging "github.com/conductorone/baton-sdk/pkg/logging" "github.com/stretchr/testify/require" ) @@ -86,6 +87,16 @@ func TestExpandCorrectness(t *testing.T) { // }, } + ctx := t.Context() + + var err error + ctx, err = sdkLogging.Init( + ctx, + sdkLogging.WithLogFormat(sdkLogging.LogFormatConsole), + sdkLogging.WithLogLevel("info"), + ) + require.NoError(t, err) + for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { unexpandedPath := getTestdataPathWithSuffix(tc.syncID, "unexpanded") @@ -98,7 +109,7 @@ func TestExpandCorrectness(t *testing.T) { t.Skipf("expanded testdata file not found: %s", expectedPath) } - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + ctx, cancel := context.WithTimeout(ctx, 5*time.Minute) defer cancel() // Copy unexpanded file to temp location