diff options
| author | Paul Buetow <paul@buetow.org> | 2021-10-03 13:09:32 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2021-10-03 13:09:32 +0300 |
| commit | 07e1470892beacf0722276f94bacbd822b002540 (patch) | |
| tree | d8073ee564eb606fb27b35f4e63bf5780ccff212 /integrationtests/dmap_test.go | |
| parent | 91ea8398ebc0febce20b9a460f9372998cd0b80f (diff) | |
add dmap tests
Diffstat (limited to 'integrationtests/dmap_test.go')
| -rw-r--r-- | integrationtests/dmap_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go new file mode 100644 index 0000000..bfca039 --- /dev/null +++ b/integrationtests/dmap_test.go @@ -0,0 +1,51 @@ +package integrationtests + +import ( + "fmt" + "os" + "testing" +) + +func TestDMap(t *testing.T) { + inFile := "mapr_testdata.log" + stdoutFile := "dmap.stdout.tmp" + csvFile := "dmap.csv.tmp" + expectedCsvFile := "dmap.csv.expected" + + query := fmt.Sprintf("from STATS select count($line),last($time),avg($goroutines),min(concurrentConnections),max(lifetimeConnections) group by $hostname outfile %s", csvFile) + + if err := runCommand(t, "../dmap", []string{"-query", query, inFile}, stdoutFile); err != nil { + t.Error(err) + return + } + + if err := compareFiles(t, csvFile, expectedCsvFile); err != nil { + t.Error(err) + return + } + + os.Remove(stdoutFile) + os.Remove(csvFile) +} + +func TestDMap2(t *testing.T) { + inFile := "mapr_testdata.log" + stdoutFile := "dmap2.stdout.tmp" + csvFile := "dmap2.csv.tmp" + expectedCsvFile := "dmap2.csv.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) + + if err := runCommand(t, "../dmap", []string{"-query", query, inFile}, stdoutFile); err != nil { + t.Error(err) + return + } + + if err := compareFilesContents(t, csvFile, expectedCsvFile); err != nil { + t.Error(err) + return + } + + os.Remove(stdoutFile) + os.Remove(csvFile) +} |
