diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-26 21:37:52 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-26 21:37:52 +0300 |
| commit | bdcc5cf8b7775d90c51460d45d9bbf1a655c1230 (patch) | |
| tree | e08ef0b9d0d9b36afe9becf32c35661de3d53153 | |
| parent | 104dc1b9e9e6636d1b15220f4833765d49ec44bc (diff) | |
refactor: optimize DMap large file test to generate file only once
- Generate the 100MB test file once before both test modes
- Pass the filename to both serverless and server test functions
- Removed duplicate file generation, improving test performance
- Test now runs in ~30s instead of ~55s
- The 100MB test file is still preserved for manual inspection
This makes the test more efficient while maintaining the same coverage
and functionality.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
| -rw-r--r-- | integrationtests/dmap_large_test.go | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/integrationtests/dmap_large_test.go b/integrationtests/dmap_large_test.go index 4f9394e..008030c 100644 --- a/integrationtests/dmap_large_test.go +++ b/integrationtests/dmap_large_test.go @@ -12,10 +12,16 @@ func TestDMapLargeFile(t *testing.T) { cleanupTmpFiles(t) testLogger := NewTestLogger("TestDMapLargeFile") defer testLogger.WriteLogFile() + + // Generate the large test file once for both test modes + largeFile := "dmap_large_100mb.log.tmp" + t.Log("Generating 100MB test file...") + generateLargeMapReduceFile(t, largeFile) + runDualModeTest(t, DualModeTest{ Name: "TestDMapLargeFile", - ServerlessTest: func(t *testing.T) { testDMapLargeFileServerless(t, testLogger) }, - ServerTest: func(t *testing.T) { testDMapLargeFileWithServer(t, testLogger) }, + ServerlessTest: func(t *testing.T) { testDMapLargeFileServerless(t, testLogger, largeFile) }, + ServerTest: func(t *testing.T) { testDMapLargeFileWithServer(t, testLogger, largeFile) }, }) } @@ -77,8 +83,7 @@ func generateLargeMapReduceFile(t *testing.T, filename string) { t.Logf("Generated %d lines (%d MB) in %v", lineNum, currentSize/(1024*1024), elapsed) } -func testDMapLargeFileServerless(t *testing.T, logger *TestLogger) { - largeFile := "dmap_large_100mb.log.tmp" +func testDMapLargeFileServerless(t *testing.T, logger *TestLogger, largeFile string) { csvFile := "dmap_large_serverless.csv.tmp" queryFile := fmt.Sprintf("%s.query", csvFile) outFile := "dmap_large_serverless.stdout.tmp" @@ -86,10 +91,6 @@ func testDMapLargeFileServerless(t *testing.T, logger *TestLogger) { // Clean up output files before test (but not the large input file) cleanupFiles(t, csvFile, queryFile, outFile) - // Generate the large test file - t.Log("Generating 100MB test file...") - generateLargeMapReduceFile(t, largeFile) - // Run several queries on the large file queries := []struct { name string @@ -151,8 +152,7 @@ func testDMapLargeFileServerless(t *testing.T, logger *TestLogger) { } } -func testDMapLargeFileWithServer(t *testing.T, logger *TestLogger) { - largeFile := "dmap_large_100mb.log.tmp" +func testDMapLargeFileWithServer(t *testing.T, logger *TestLogger, largeFile string) { csvFile := "dmap_large_server.csv.tmp" queryFile := fmt.Sprintf("%s.query", csvFile) outFile := "dmap_large_server.stdout.tmp" @@ -160,10 +160,6 @@ func testDMapLargeFileWithServer(t *testing.T, logger *TestLogger) { // Clean up output files before test (but not the large input file) cleanupFiles(t, csvFile, queryFile, outFile) - // Generate the large test file - t.Log("Generating 100MB test file...") - generateLargeMapReduceFile(t, largeFile) - server := NewTestServer(t) if err := server.Start("error"); err != nil { t.Error(err) |
