diff options
| author | Paul Buetow <paul@buetow.org> | 2021-10-09 21:10:29 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2021-10-10 13:36:41 +0300 |
| commit | 97747ea0f3178f7f5890512d483fdccaa82846b0 (patch) | |
| tree | 9ff1335ca26afc90e55fd6de416457e252d75a35 /integrationtests/dmap_test.go | |
| parent | 7a7169791a64190e1002e38bc9c04ad0d5c1ce1f (diff) | |
vetting and linting and some code restyling
Diffstat (limited to 'integrationtests/dmap_test.go')
| -rw-r--r-- | integrationtests/dmap_test.go | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go index b512985..f5c78e0 100644 --- a/integrationtests/dmap_test.go +++ b/integrationtests/dmap_test.go @@ -14,9 +14,12 @@ func TestDMap(t *testing.T) { queryFile := fmt.Sprintf("%s.query", csvFile) expectedQueryFile := "dmap.csv.query.expected" - query := fmt.Sprintf("from STATS select count($line),last($time),avg($goroutines),min(concurrentConnections),max(lifetimeConnections) group by $hostname outfile %s", csvFile) + query := fmt.Sprintf("from STATS select count($line),last($time),"+ + "avg($goroutines),min(concurrentConnections),max(lifetimeConnections) "+ + "group by $hostname outfile %s", csvFile) + args := []string{"-query", query, inFile} - if _, err := runCommand(t, "../dmap", []string{"-query", query, inFile}, stdoutFile); err != nil { + if _, err := runCommand(t, "../dmap", args, stdoutFile); err != nil { t.Error(err) return } @@ -42,9 +45,48 @@ func TestDMap2(t *testing.T) { queryFile := fmt.Sprintf("%s.query", csvFile) expectedQueryFile := "dmap2.csv.query.expected" - query := fmt.Sprintf("from STATS select count($time),$time,max($goroutines),avg($goroutines),min($goroutines) group by $time order by count($time) outfile %s", csvFile) + query := fmt.Sprintf("from STATS select count($time),$time,max($goroutines),"+ + "avg($goroutines),min($goroutines) group by $time order by count($time) "+ + "outfile %s", csvFile) - if _, err := runCommand(t, "../dmap", []string{"-query", query, inFile}, stdoutFile); err != nil { + args := []string{"-query", query, inFile} + if _, err := runCommand(t, "../dmap", args, stdoutFile); err != nil { + t.Error(err) + return + } + 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(stdoutFile) + os.Remove(csvFile) + os.Remove(queryFile) +} + +func TestDMap3(t *testing.T) { + inFile := "mapr_testdata.log" + stdoutFile := "dmap3.stdout.tmp" + csvFile := "dmap3.csv.tmp" + expectedCsvFile := "dmap3.csv.expected" + queryFile := fmt.Sprintf("%s.query", csvFile) + expectedQueryFile := "dmap3.csv.query.expected" + + query := fmt.Sprintf("from STATS select count($time),$time,max($goroutines),"+ + "avg($goroutines),min($goroutines) group by $time order by count($time) "+ + "outfile %s", csvFile) + + // Read many input files at once. + args := []string{"-query", query} + for i := 0; i < 100; i++ { + args = append(args, inFile) + } + + if _, err := runCommand(t, "../dmap", args, stdoutFile); err != nil { t.Error(err) return } |
