summaryrefslogtreecommitdiff
path: root/integrationtests/dtail_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-10 19:42:48 +0300
committerPaul Buetow <paul@buetow.org>2021-10-11 11:52:30 +0300
commit71f89dc7ec7cf993d1eca98771212afe6310e9c8 (patch)
treeca2812fb142b2d98f8a8092992a33d575329997a /integrationtests/dtail_test.go
parentf44792c9102488774c9993b080f35c65287a64b1 (diff)
refactor
Diffstat (limited to 'integrationtests/dtail_test.go')
-rw-r--r--integrationtests/dtail_test.go90
1 files changed, 88 insertions, 2 deletions
diff --git a/integrationtests/dtail_test.go b/integrationtests/dtail_test.go
index 36eadc0..267cd26 100644
--- a/integrationtests/dtail_test.go
+++ b/integrationtests/dtail_test.go
@@ -1,16 +1,102 @@
package integrationtests
import (
+ "context"
"os"
"testing"
)
+func TestDTailWithServer(t *testing.T) {
+ followFile := "dtail.follow.tmp"
+ //serverStdoutFile := "dtail.dserver.stdout.tmp"
+ //greetings := []string{"world", "sol system", "milky way", "universe", "multiverse"}
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ serverCh, _, _, err := startCommand(ctx,
+ "../dserver",
+ "--logger", "stdout",
+ "--logLevel", "info",
+ "--port", "4242",
+ "--relaxedAuth",
+ )
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ clientCh, _, _, err := startCommand(ctx,
+ "../dtail",
+ "--logger", "stdout",
+ "--logLevel", "devel",
+ "--servers", "localhost:4242",
+ "--files", followFile,
+ "--grep", "Hello",
+ "--trustAllHosts",
+ "--noColor",
+ )
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ for {
+ select {
+ case line := <-serverCh:
+ t.Log("server:", line)
+ case line := <-clientCh:
+ t.Log("client:", line)
+ case <-ctx.Done():
+ t.Log("Done reading client and server pipes")
+ }
+ }
+
+ /*
+ // Start dtail client, connect to the server and follow followFile.
+
+ //clientStdoutFile := "dtail.stdout.tmp"
+ /*
+
+ t.Log(clientArgs)
+ // TODO: Pipe with dtail command to read stdin stream.
+ // runCommandContextRetry(ctx, t, "../dtail", clientArgs, clientStdoutFile)
+
+ // Write greetings to followFile
+ fd, err := os.Create(followFile)
+ if err != nil {
+ t.Error(err)
+ }
+ defer fd.Close()
+
+ go func() {
+ var circular int
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-time.After(time.Second):
+ fd.WriteString(time.Now().String())
+ fd.WriteString(fmt.Sprintf(" - Hello %s!\n", greetings[circular]))
+ circular = (circular + 1) % len(greetings)
+ }
+ }
+ }()
+ */
+
+ /*
+ os.Remove(serverStdoutFile)
+ os.Remove(clientStdoutFile)
+ os.Remove(followFile)
+ */
+}
+
func TestDTailColorTable(t *testing.T) {
stdoutFile := "dtailcolortable.stdout.tmp"
expectedStdoutFile := "dtailcolortable.expected"
- args := []string{"-colorTable"}
- if _, err := runCommand(t, "../dtail", args, stdoutFile); err != nil {
+ _, err := runCommand(context.TODO(), stdoutFile, "../dtail", "--colorTable")
+ if err != nil {
t.Error(err)
return
}