From bee83cd299b3259790d62b9f22347498f70206b7 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 14 Mar 2022 13:59:51 +0000 Subject: "append" now actually will append to an outfile now. previously we only added the syntax to the mapr query --- integrationtests/dmap_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'integrationtests/dmap_test.go') diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go index d466d9f..346a872 100644 --- a/integrationtests/dmap_test.go +++ b/integrationtests/dmap_test.go @@ -65,7 +65,7 @@ func testDmap1(t *testing.T, query, subtestName string, usePipe bool) error { "--cfg", "none", "--query", query, "--logger", "stdout", - "--logLevel", "error", + "--logLevel", "info", "--noColor") } else { stdoutCh, stderrCh, cmdErrCh, err = startCommand(ctx, t, @@ -73,7 +73,7 @@ func testDmap1(t *testing.T, query, subtestName string, usePipe bool) error { "--cfg", "none", "--query", query, "--logger", "stdout", - "--logLevel", "error", + "--logLevel", "info", "--noColor", inFile) } -- cgit v1.2.3 From e085a61ca70932a3670381e2d6b5919e9108441d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 14 Mar 2022 16:31:19 +0000 Subject: add integration test for "outfile append.." --- integrationtests/dmap_test.go | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'integrationtests/dmap_test.go') diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go index 346a872..600aaa9 100644 --- a/integrationtests/dmap_test.go +++ b/integrationtests/dmap_test.go @@ -189,3 +189,59 @@ func TestDMap3(t *testing.T) { os.Remove(csvFile) os.Remove(queryFile) } + +func TestDMap4Append(t *testing.T) { + if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") { + t.Log("Skipping") + return + } + inFile := "mapr_testdata.log" + outFile := "dmap4.stdout.tmp" + csvFile := "dmap4.csv.tmp" + expectedCsvFile := "dmap4.csv.expected" + queryFile := fmt.Sprintf("%s.query", csvFile) + expectedQueryFile := "dmap4.csv.query.expected" + + // Delete in case it exists already. Otherwise, test will fail. + os.Remove(csvFile) + + query := fmt.Sprintf("from STATS select count($time),$time,max($goroutines),"+ + "avg($goroutines),min($goroutines) group by $time order by count($time) "+ + "outfile append %s", csvFile) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + // Run dmap command twice, it should append in the 2nd iteration the new results to the already existing + // fille as we specified "outfile append". That works transparently for any mapreduce query + // (e.g. also for the dtail command in streaming mode). But it is easier to test with the dmap + // command. + for i := 0; i < 2; i++ { + stdoutCh, stderrCh, cmdErrCh, err := startCommand(ctx, t, + "", "../dmap", + "--query", query, + "--cfg", "none", + "--logger", "stdout", + "--logLevel", "info", + "--noColor", inFile) + + if err != nil { + t.Error(err) + return + } + waitForCommand(ctx, t, stdoutCh, stderrCh, cmdErrCh) + } + + if err := compareFilesContents(t, csvFile, expectedCsvFile); err != nil { + t.Error(err) + return + } + if err := compareFiles(t, queryFile, expectedQueryFile); err != nil { + t.Error(err) + return + } + + os.Remove(outFile) + os.Remove(csvFile) + os.Remove(queryFile) +} -- cgit v1.2.3 From d9601ca860367ec8ddf6bc5c108c826723a81abd Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 14 Mar 2022 17:33:20 +0000 Subject: typo --- integrationtests/dmap_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'integrationtests/dmap_test.go') diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go index 600aaa9..a378fb5 100644 --- a/integrationtests/dmap_test.go +++ b/integrationtests/dmap_test.go @@ -213,7 +213,7 @@ func TestDMap4Append(t *testing.T) { defer cancel() // Run dmap command twice, it should append in the 2nd iteration the new results to the already existing - // fille as we specified "outfile append". That works transparently for any mapreduce query + // file as we specified "outfile append". That works transparently for any mapreduce query // (e.g. also for the dtail command in streaming mode). But it is easier to test with the dmap // command. for i := 0; i < 2; i++ { -- cgit v1.2.3