From 86ec83754e0ee7153ad55091f7b6da448bc529c5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 2 Oct 2021 13:44:27 +0300 Subject: add dcat test --- integrationtests/dcat_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 integrationtests/dcat_test.go (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go new file mode 100644 index 0000000..370ea25 --- /dev/null +++ b/integrationtests/dcat_test.go @@ -0,0 +1,22 @@ +package integrationtests + +import ( + "os" + "testing" +) + +func TestDCat(t *testing.T) { + testdataFile := "testdata.txt" + stdoutFile := "dcat.out" + + if err := runCommand(t, "../dcat", []string{"-spartan", testdataFile}, stdoutFile); err != nil { + t.Error(err) + return + } + + if err := compareFiles(t, stdoutFile, testdataFile); err != nil { + t.Error(err) + return + } + os.Remove(stdoutFile) +} -- cgit v1.2.3 From 2d7ddbeae8286373ac19787dc7dde598a7cb0598 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 8 Oct 2021 11:43:43 +0300 Subject: refactor --- integrationtests/dcat_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go index 370ea25..4394552 100644 --- a/integrationtests/dcat_test.go +++ b/integrationtests/dcat_test.go @@ -6,7 +6,7 @@ import ( ) func TestDCat(t *testing.T) { - testdataFile := "testdata.txt" + testdataFile := "dcat.txt.expected" stdoutFile := "dcat.out" if err := runCommand(t, "../dcat", []string{"-spartan", testdataFile}, stdoutFile); err != nil { -- cgit v1.2.3 From 7a7169791a64190e1002e38bc9c04ad0d5c1ce1f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 9 Oct 2021 16:44:28 +0300 Subject: add dtail health check unit test. --- integrationtests/dcat_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go index 4394552..a164960 100644 --- a/integrationtests/dcat_test.go +++ b/integrationtests/dcat_test.go @@ -9,7 +9,7 @@ func TestDCat(t *testing.T) { testdataFile := "dcat.txt.expected" stdoutFile := "dcat.out" - if err := runCommand(t, "../dcat", []string{"-spartan", testdataFile}, stdoutFile); err != nil { + if _, err := runCommand(t, "../dcat", []string{"-spartan", testdataFile}, stdoutFile); err != nil { t.Error(err) return } -- cgit v1.2.3 From 97747ea0f3178f7f5890512d483fdccaa82846b0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 9 Oct 2021 21:10:29 +0300 Subject: vetting and linting and some code restyling --- integrationtests/dcat_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go index a164960..342ebd0 100644 --- a/integrationtests/dcat_test.go +++ b/integrationtests/dcat_test.go @@ -8,12 +8,12 @@ import ( func TestDCat(t *testing.T) { testdataFile := "dcat.txt.expected" stdoutFile := "dcat.out" + args := []string{"-spartan", testdataFile} - if _, err := runCommand(t, "../dcat", []string{"-spartan", testdataFile}, stdoutFile); err != nil { + if _, err := runCommand(t, "../dcat", args, stdoutFile); err != nil { t.Error(err) return } - if err := compareFiles(t, stdoutFile, testdataFile); err != nil { t.Error(err) return -- cgit v1.2.3 From 71f89dc7ec7cf993d1eca98771212afe6310e9c8 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 10 Oct 2021 19:42:48 +0300 Subject: refactor --- integrationtests/dcat_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go index 342ebd0..e172bfa 100644 --- a/integrationtests/dcat_test.go +++ b/integrationtests/dcat_test.go @@ -1,6 +1,7 @@ package integrationtests import ( + "context" "os" "testing" ) @@ -8,15 +9,19 @@ import ( func TestDCat(t *testing.T) { testdataFile := "dcat.txt.expected" stdoutFile := "dcat.out" - args := []string{"-spartan", testdataFile} - if _, err := runCommand(t, "../dcat", args, stdoutFile); err != nil { + _, err := runCommand(context.TODO(), stdoutFile, + "../dcat", "--spartan", testdataFile) + + if err != nil { t.Error(err) return } + if err := compareFiles(t, stdoutFile, testdataFile); err != nil { t.Error(err) return } + os.Remove(stdoutFile) } -- cgit v1.2.3 From 7b873100d94ddc3c698a620cb83b61dcb2074303 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 13 Oct 2021 09:00:03 +0300 Subject: add another dcat integration test - catting 100 files at once --- integrationtests/dcat_test.go | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go index e172bfa..5dfd08e 100644 --- a/integrationtests/dcat_test.go +++ b/integrationtests/dcat_test.go @@ -7,10 +7,10 @@ import ( ) func TestDCat(t *testing.T) { - testdataFile := "dcat.txt.expected" + testdataFile := "dcat.txt" stdoutFile := "dcat.out" - _, err := runCommand(context.TODO(), stdoutFile, + _, err := runCommand(context.TODO(), t, stdoutFile, "../dcat", "--spartan", testdataFile) if err != nil { @@ -25,3 +25,29 @@ func TestDCat(t *testing.T) { os.Remove(stdoutFile) } + +func TestDCat2(t *testing.T) { + testdataFile := "dcat2.txt" + expectedFile := "dcat2.txt.expected" + stdoutFile := "dcat2.out" + + args := []string{"--spartan", "--logLevel", "error"} + + // Cat file 100 times in one session. + for i := 0; i < 100; i++ { + args = append(args, testdataFile) + } + + if _, err := runCommand(context.TODO(), t, stdoutFile, "../dcat", args...); err != nil { + t.Error(err) + return + } + + if err := compareFilesContents(t, stdoutFile, expectedFile); err != nil { + t.Error(err) + return + } + + os.Remove(stdoutFile) + os.Remove(expectedFile) +} -- cgit v1.2.3 From 698fb76b98c46c677abe13fdc93afc6c4f38c39e Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 14 Oct 2021 20:55:35 +0300 Subject: refactor --- integrationtests/dcat_test.go | 1 - 1 file changed, 1 deletion(-) (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go index 5dfd08e..bd2efe5 100644 --- a/integrationtests/dcat_test.go +++ b/integrationtests/dcat_test.go @@ -49,5 +49,4 @@ func TestDCat2(t *testing.T) { } os.Remove(stdoutFile) - os.Remove(expectedFile) } -- cgit v1.2.3 From c0332e8fa13f4939de17c856b2e71fd093847253 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 15 Oct 2021 09:04:40 +0300 Subject: add dcat color output test --- integrationtests/dcat_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go index bd2efe5..fd5db5d 100644 --- a/integrationtests/dcat_test.go +++ b/integrationtests/dcat_test.go @@ -50,3 +50,24 @@ func TestDCat2(t *testing.T) { os.Remove(stdoutFile) } + +func TestDCatColors(t *testing.T) { + testdataFile := "dcatcolors.txt" + stdoutFile := "dcatcolors.out" + expectedFile := "dcatcolors.expected" + + _, err := runCommand(context.TODO(), t, stdoutFile, + "../dcat", "--logLevel", "error", testdataFile) + + if err != nil { + t.Error(err) + return + } + + if err := compareFiles(t, stdoutFile, expectedFile); err != nil { + t.Error(err) + return + } + + os.Remove(stdoutFile) +} -- cgit v1.2.3 From b27fc108ecd6eead5c97cf6e894bf8d639fff75c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 15 Oct 2021 13:06:18 +0300 Subject: Execute test directories individually --- integrationtests/dcat_test.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go index fd5db5d..afcb94c 100644 --- a/integrationtests/dcat_test.go +++ b/integrationtests/dcat_test.go @@ -51,6 +51,9 @@ func TestDCat2(t *testing.T) { os.Remove(stdoutFile) } +/* +// TODO: The test currently fails as there is a hostname in the output. What needs +// to be done is to ignore the hostnames in the output (which is field 2 of the output) func TestDCatColors(t *testing.T) { testdataFile := "dcatcolors.txt" stdoutFile := "dcatcolors.out" @@ -71,3 +74,4 @@ func TestDCatColors(t *testing.T) { os.Remove(stdoutFile) } +*/ -- cgit v1.2.3 From 860c41441b3bcf542b5701ae2257812879ce47b4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 19 Oct 2021 19:01:12 +0300 Subject: Set DTAIL_RUN_INTEGRATIONT_TEST to yes for integration tests --- integrationtests/dcat_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'integrationtests/dcat_test.go') diff --git a/integrationtests/dcat_test.go b/integrationtests/dcat_test.go index afcb94c..2516867 100644 --- a/integrationtests/dcat_test.go +++ b/integrationtests/dcat_test.go @@ -4,9 +4,15 @@ import ( "context" "os" "testing" + + "github.com/mimecast/dtail/internal/config" ) func TestDCat(t *testing.T) { + if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") { + t.Log("Skipping") + return + } testdataFile := "dcat.txt" stdoutFile := "dcat.out" @@ -27,6 +33,9 @@ func TestDCat(t *testing.T) { } func TestDCat2(t *testing.T) { + if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") { + return + } testdataFile := "dcat2.txt" expectedFile := "dcat2.txt.expected" stdoutFile := "dcat2.out" @@ -55,6 +64,9 @@ func TestDCat2(t *testing.T) { // TODO: The test currently fails as there is a hostname in the output. What needs // to be done is to ignore the hostnames in the output (which is field 2 of the output) func TestDCatColors(t *testing.T) { + if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") { + return + } testdataFile := "dcatcolors.txt" stdoutFile := "dcatcolors.out" expectedFile := "dcatcolors.expected" -- cgit v1.2.3