summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2021-10-19 19:01:12 +0300
committerPaul Buetow <pbuetow@mimecast.com>2021-10-19 19:03:03 +0300
commit860c41441b3bcf542b5701ae2257812879ce47b4 (patch)
tree9940e557b86e346cc3989c45e4f512f58dab850b
parent10314cef906fd9b73e003be69c2f6b7b3d66570c (diff)
Set DTAIL_RUN_INTEGRATIONT_TEST to yes for integration tests
-rw-r--r--Makefile6
-rw-r--r--TODO.md1
-rw-r--r--doc/installation.md4
-rw-r--r--integrationtests/dcat_test.go12
-rw-r--r--integrationtests/dgrep_test.go18
-rw-r--r--integrationtests/dmap_test.go14
-rw-r--r--integrationtests/dtail_test.go10
-rw-r--r--integrationtests/dtailhealth_test.go14
-rw-r--r--internal/config/env.go7
-rw-r--r--internal/config/initializer.go4
10 files changed, 83 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 6c644f7..0e66ac4 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ DTAIL_SSH_DONT_ADD_HOSTS_TO_KNOWNHOSTS_FILE = yes
all: build
build: dserver dcat dgrep dmap dtail dtailhealth
dserver:
-ifndef USE_ACL
+ifndef DTAIL_USE_ACL
${GO} build ${GO_FLAGS} -o dserver ./cmd/dserver/main.go
else
${GO} build ${GO_FLAGS} -tags linuxacl -o dserver ./cmd/dserver/main.go
@@ -20,7 +20,7 @@ dtail:
dtailhealth:
${GO} build ${GO_FLAGS} -o dtailhealth ./cmd/dtailhealth/main.go
install:
-ifndef USE_ACL
+ifndef DTAIL_USE_ACL
${GO} install ./cmd/dserver/main.go
else
${GO} install -tags linuxacl ./cmd/dserver/main.go
@@ -48,7 +48,7 @@ lint:
done | grep -F .go:
test:
${GO} clean -testcache
-ifndef USE_ACL
+ifndef DTAIL_USE_ACL
set -e; find . -name '*_test.go' | while read file; do dirname $$file; done | \
sort -u | while read dir; do ${GO} test --race -v $$dir || exit 2; done
else
diff --git a/TODO.md b/TODO.md
index ae2ab47..9235785 100644
--- a/TODO.md
+++ b/TODO.md
@@ -16,3 +16,4 @@ This is a loose list of what to do. Maybe for the next releae or maybe for a lat
[ ] More integration test colors (via dcat?)
[ ] Integration test for dtail in serverless mode
[x] Integration test for dtail normal mode
+[ ] Document how to run ingeration tests
diff --git a/doc/installation.md b/doc/installation.md
index 8f3892c..0f6143b 100644
--- a/doc/installation.md
+++ b/doc/installation.md
@@ -19,10 +19,10 @@ This is optional, but it gives you better security. On Linux, you have the optio
### 2. Enable ACL via a Go build flag
-Set the `USE_ACL` environment variable before invoking the make command.
+Set the `DTAIL_USE_ACL` environment variable before invoking the make command.
```console
-% export USE_ACL=yes
+% export DTAIL_USE_ACL=yes
```
Alternatively, you could add `-tags linuxacl` to the Go compiler.
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"
diff --git a/integrationtests/dgrep_test.go b/integrationtests/dgrep_test.go
index b63ac45..8fe0a49 100644
--- a/integrationtests/dgrep_test.go
+++ b/integrationtests/dgrep_test.go
@@ -4,9 +4,15 @@ import (
"context"
"os"
"testing"
+
+ "github.com/mimecast/dtail/internal/config"
)
func TestDGrep(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
inFile := "mapr_testdata.log"
stdoutFile := "dgrep.stdout.tmp"
expectedStdoutFile := "dgrep.txt.expected"
@@ -28,6 +34,10 @@ func TestDGrep(t *testing.T) {
}
func TestDGrep2(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
inFile := "mapr_testdata.log"
stdoutFile := "dgrep2.stdout.tmp"
expectedStdoutFile := "dgrep2.txt.expected"
@@ -49,6 +59,10 @@ func TestDGrep2(t *testing.T) {
}
func TestDGrepContext(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
inFile := "mapr_testdata.log"
stdoutFile := "dgrepcontext.stdout.tmp"
expectedStdoutFile := "dgrepcontext.txt.expected"
@@ -71,6 +85,10 @@ func TestDGrepContext(t *testing.T) {
}
func TestDGrepContext2(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
inFile := "mapr_testdata.log"
stdoutFile := "dgrepcontext2.stdout.tmp"
expectedStdoutFile := "dgrepcontext2.txt.expected"
diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go
index a112456..b3c048a 100644
--- a/integrationtests/dmap_test.go
+++ b/integrationtests/dmap_test.go
@@ -5,9 +5,15 @@ import (
"fmt"
"os"
"testing"
+
+ "github.com/mimecast/dtail/internal/config"
)
func TestDMap(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
inFile := "mapr_testdata.log"
stdoutFile := "dmap.stdout.tmp"
csvFile := "dmap.csv.tmp"
@@ -42,6 +48,10 @@ func TestDMap(t *testing.T) {
}
func TestDMap2(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
inFile := "mapr_testdata.log"
stdoutFile := "dmap2.stdout.tmp"
csvFile := "dmap2.csv.tmp"
@@ -75,6 +85,10 @@ func TestDMap2(t *testing.T) {
}
func TestDMap3(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
inFile := "mapr_testdata.log"
stdoutFile := "dmap3.stdout.tmp"
csvFile := "dmap3.csv.tmp"
diff --git a/integrationtests/dtail_test.go b/integrationtests/dtail_test.go
index 4af7401..c6d0107 100644
--- a/integrationtests/dtail_test.go
+++ b/integrationtests/dtail_test.go
@@ -7,9 +7,15 @@ import (
"strings"
"testing"
"time"
+
+ "github.com/mimecast/dtail/internal/config"
)
func TestDTailWithServer(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
followFile := "dtail.follow.tmp"
greetings := []string{"world!", "sol-system!", "milky-way!", "universe!", "multiverse!"}
@@ -122,6 +128,10 @@ func TestDTailWithServer(t *testing.T) {
}
func TestDTailColorTable(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
stdoutFile := "dtailcolortable.stdout.tmp"
expectedStdoutFile := "dtailcolortable.expected"
diff --git a/integrationtests/dtailhealth_test.go b/integrationtests/dtailhealth_test.go
index 87ed648..8c0918f 100644
--- a/integrationtests/dtailhealth_test.go
+++ b/integrationtests/dtailhealth_test.go
@@ -5,9 +5,15 @@ import (
"fmt"
"os"
"testing"
+
+ "github.com/mimecast/dtail/internal/config"
)
func TestDTailHealthCheck(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
stdoutFile := "dtailhealth.stdout.tmp"
expectedStdoutFile := "dtailhealth.expected"
@@ -26,6 +32,10 @@ func TestDTailHealthCheck(t *testing.T) {
}
func TestDTailHealthCheck2(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
stdoutFile := "dtailhealth2.stdout.tmp"
expectedStdoutFile := "dtailhealth2.expected"
@@ -47,6 +57,10 @@ func TestDTailHealthCheck2(t *testing.T) {
}
func TestDTailHealthCheck3(t *testing.T) {
+ if !config.Env("DTAIL_RUN_INTEGRATION_TESTS") {
+ t.Log("Skipping")
+ return
+ }
stdoutFile := "dtailhealth3.stdout.tmp"
expectedStdoutFile := "dtailhealth3.expected"
diff --git a/internal/config/env.go b/internal/config/env.go
new file mode 100644
index 0000000..88b831d
--- /dev/null
+++ b/internal/config/env.go
@@ -0,0 +1,7 @@
+package config
+
+import "os"
+
+func Env(env string) bool {
+ return "yes" == os.Getenv(env)
+}
diff --git a/internal/config/initializer.go b/internal/config/initializer.go
index 35105bf..4d6a73b 100644
--- a/internal/config/initializer.go
+++ b/internal/config/initializer.go
@@ -82,8 +82,8 @@ func (in *initializer) transformConfig(sourceProcess source.Source, args *Args,
// There are some special options which can be set by environment variable.
func (in *initializer) readEnvironmentVars() {
- if len(os.Getenv("DTAIL_SSH_DONT_ADD_HOSTS_TO_KNOWNHOSTS_FILE")) != 0 ||
- len(os.Getenv("DTAIL_JENKINS")) != 0 {
+ if Env("DTAIL_SSH_DONT_ADD_HOSTS_TO_KNOWNHOSTS_FILE") ||
+ Env("DTAIL_JENKINS") {
in.Client.SSHDontAddHostsToKnownHostsFile = true
}
}