Skip to content

Commit

Permalink
appveyor: Run logmon tests
Browse files Browse the repository at this point in the history
  • Loading branch information
endocrimes committed Jun 28, 2019
1 parent e6daf3b commit 5ef76e3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ test_script:
gotestsum --junitfile results.xml
github.com/hashicorp/nomad/drivers/docker
github.com/hashicorp/nomad/client/lib/fifo
github.com/hashicorp/nomad/client/logmon
# on_finish:
# - ps: |
# Push-AppveyorArtifact (Resolve-Path .\results.xml)
Expand Down
5 changes: 3 additions & 2 deletions client/lib/fifo/fifo_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fifo

import (
"fmt"
"io"
"net"
"os"
Expand Down Expand Up @@ -75,7 +76,7 @@ func CreateAndRead(path string) (func() (io.ReadCloser, error), error) {
OutputBufferSize: PipeBufferSize,
})
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to create fifo: %v", err)
}

return func() (io.ReadCloser, error) {
Expand All @@ -88,7 +89,7 @@ func CreateAndRead(path string) (func() (io.ReadCloser, error), error) {
func OpenReader(path string) (io.ReadCloser, error) {
l, err := winio.ListenOnlyPipe(path, nil)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to open fifo listener: %v", err)
}

return &winFIFO{listener: l}, nil
Expand Down
37 changes: 29 additions & 8 deletions client/logmon/logmon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/hashicorp/nomad/client/lib/fifo"
Expand All @@ -16,13 +17,23 @@ import (

func TestLogmon_Start_rotate(t *testing.T) {
require := require.New(t)

stdoutLog := "stdout"
stderrLog := "stderr"

var stdoutFifoPath, stderrFifoPath string

dir, err := ioutil.TempDir("", "nomadtest")
require.NoError(err)
defer os.RemoveAll(dir)
stdoutLog := "stdout"
stdoutFifoPath := filepath.Join(dir, "stdout.fifo")
stderrLog := "stderr"
stderrFifoPath := filepath.Join(dir, "stderr.fifo")

if runtime.GOOS == "windows" {
stdoutFifoPath = "//./pipe/test-rotate.stdout"
stderrFifoPath = "//./pipe/test-rotate.stderr"
} else {
stdoutFifoPath = filepath.Join(dir, "stdout.fifo")
stderrFifoPath = filepath.Join(dir, "stderr.fifo")
}

cfg := &LogConfig{
LogDir: dir,
Expand Down Expand Up @@ -69,13 +80,23 @@ func TestLogmon_Start_rotate(t *testing.T) {
// asserts that calling Start twice restarts the log rotator
func TestLogmon_Start_restart(t *testing.T) {
require := require.New(t)

stdoutLog := "stdout"
stderrLog := "stderr"

var stdoutFifoPath, stderrFifoPath string

dir, err := ioutil.TempDir("", "nomadtest")
require.NoError(err)
defer os.RemoveAll(dir)
stdoutLog := "stdout"
stdoutFifoPath := filepath.Join(dir, "stdout.fifo")
stderrLog := "stderr"
stderrFifoPath := filepath.Join(dir, "stderr.fifo")

if runtime.GOOS == "windows" {
stdoutFifoPath = "//./pipe/test-restart.stdout"
stderrFifoPath = "//./pipe/test-restart.stderr"
} else {
stdoutFifoPath = filepath.Join(dir, "stdout.fifo")
stderrFifoPath = filepath.Join(dir, "stderr.fifo")
}

cfg := &LogConfig{
LogDir: dir,
Expand Down

0 comments on commit 5ef76e3

Please sign in to comment.