Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions pkg/dotc1z/race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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],
Expand All @@ -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],
Expand Down Expand Up @@ -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)
Expand All @@ -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))

Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion pkg/sync/expand/expand_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion pkg/sync/expand/expand_correctness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down
Loading