Merge pull request #532 from nats-io/fix_windows

Fix "error opening file" errors in tests for Windows
This commit is contained in:
Ivan Kozlovic
2017-07-10 17:26:15 -06:00
committed by GitHub
22 changed files with 30 additions and 31 deletions

View File

@@ -11,7 +11,6 @@ authorization {
}
pid_file: '/tmp/nats_cluster_test.pid'
log_file: '/tmp/nats_cluster_test.log'
cluster {
host: 127.0.0.1

View File

@@ -1,7 +1,6 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
authorization {
# Our role based permissions.

View File

@@ -1,7 +1,6 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
authorization {
# Our role based permissions.

View File

@@ -1,4 +1,3 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"

View File

@@ -1,6 +1,5 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
max_connections: 1

View File

@@ -1,6 +1,5 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
max_payload: 1

View File

@@ -1,7 +1,6 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
authorization {
users = [

View File

@@ -1,7 +1,6 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
authorization {
users = [

View File

@@ -1,12 +1,12 @@
# Copyright 2017 Apcera Inc. All rights reserved.
include 'platform.conf'
# logging options
debug: true # enable on reload
trace: true # enable on reload
logtime: true # enable on reload
syslog: true # enable on reload
remote_syslog: "udp://localhost:514" # change on reload
log_file: "/tmp/gnatsd-2.log" # change on reload
pid_file: "/tmp/gnatsd.pid" # change on reload
max_control_line: 512 # change on reload

View File

@@ -4,4 +4,3 @@
debug: false
trace: true
logtime: true # logtime not supported on config reload
log_file: "/tmp/gnatsd.log"

View File

@@ -1,7 +1,6 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
authorization {
user: tyler

View File

@@ -1,7 +1,6 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
authorization {
user: derek

View File

@@ -4,7 +4,6 @@
debug: false
trace: false
logtime: false
log_file: "/tmp/gnatsd.log"
cluster {
listen: localhost:-1

View File

@@ -3,7 +3,6 @@
# Simple TLS config file
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
tls {
cert_file: "./configs/certs/server.pem"

View File

@@ -3,7 +3,6 @@
# Simple TLS config file
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
tls {
cert_file: "./configs/certs/cert.new.pem"

View File

@@ -1,7 +1,6 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
authorization {
token: T0pS3cr3t

View File

@@ -1,7 +1,6 @@
# Copyright 2017 Apcera Inc. All rights reserved.
listen: localhost:-1
log_file: "/tmp/gnatsd.log"
authorization {
token: passw0rd

View File

@@ -16,7 +16,6 @@ authorization {
debug: false
trace: true
logtime: false
log_file: "/tmp/gnatsd.log"
syslog: true
remote_syslog: "udp://foo.com:33"

View File

@@ -64,7 +64,6 @@ func TestConfigFile(t *testing.T) {
Trace: true,
Logtime: false,
HTTPPort: 8222,
LogFile: "/tmp/gnatsd.log",
PidFile: "/tmp/gnatsd.pid",
ProfPort: 6543,
Syslog: true,
@@ -220,7 +219,6 @@ func TestMergeOverrides(t *testing.T) {
Trace: true,
Logtime: false,
HTTPPort: DEFAULT_HTTP_PORT,
LogFile: "/tmp/gnatsd.log",
PidFile: "/tmp/gnatsd.pid",
ProfPort: 6789,
Syslog: true,
@@ -714,7 +712,6 @@ func TestOptionsClone(t *testing.T) {
Trace: true,
Logtime: false,
HTTPPort: DEFAULT_HTTP_PORT,
LogFile: "/tmp/gnatsd.log",
PidFile: "/tmp/gnatsd.pid",
ProfPort: 6789,
Syslog: true,

View File

@@ -4,10 +4,12 @@ package server
import (
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"reflect"
"runtime"
"strings"
"testing"
"time"
@@ -33,6 +35,7 @@ func TestConfigReloadNoConfigFile(t *testing.T) {
func TestConfigReloadUnsupported(t *testing.T) {
server, opts, config := newServerWithSymlinkConfig(t, "tmp.conf", "./configs/reload/test.conf")
defer os.Remove(config)
defer server.Shutdown()
loaded := server.ConfigTime()
@@ -44,7 +47,6 @@ func TestConfigReloadUnsupported(t *testing.T) {
Debug: false,
Trace: false,
Logtime: false,
LogFile: "/tmp/gnatsd.log",
MaxControlLine: 1024,
MaxPayload: 1048576,
MaxConn: 65536,
@@ -91,6 +93,7 @@ func TestConfigReloadUnsupported(t *testing.T) {
func TestConfigReloadInvalidConfig(t *testing.T) {
server, opts, config := newServerWithSymlinkConfig(t, "tmp.conf", "./configs/reload/test.conf")
defer os.Remove(config)
defer server.Shutdown()
loaded := server.ConfigTime()
@@ -102,7 +105,6 @@ func TestConfigReloadInvalidConfig(t *testing.T) {
Debug: false,
Trace: false,
Logtime: false,
LogFile: "/tmp/gnatsd.log",
MaxControlLine: 1024,
MaxPayload: 1048576,
MaxConn: 65536,
@@ -147,8 +149,21 @@ func TestConfigReloadInvalidConfig(t *testing.T) {
// Ensure Reload returns nil and the config is changed on success.
func TestConfigReload(t *testing.T) {
var content []byte
if runtime.GOOS != "windows" {
content = []byte(`
remote_syslog: "udp://localhost:514" # change on reload
log_file: "/tmp/gnatsd-2.log" # change on reload
`)
}
platformConf := "platform.conf"
defer os.Remove(platformConf)
if err := ioutil.WriteFile(platformConf, content, 0666); err != nil {
t.Fatalf("Unable to write config file: %v", err)
}
server, opts, config := newServerWithSymlinkConfig(t, "tmp.conf", "./configs/reload/test.conf")
defer os.Remove(config)
defer server.Shutdown()
loaded := server.ConfigTime()
@@ -160,7 +175,6 @@ func TestConfigReload(t *testing.T) {
Debug: false,
Trace: false,
Logtime: false,
LogFile: "/tmp/gnatsd.log",
MaxControlLine: 1024,
MaxPayload: 1048576,
MaxConn: 65536,
@@ -202,14 +216,16 @@ func TestConfigReload(t *testing.T) {
if !updated.Logtime {
t.Fatal("Expected Logtime to be true")
}
if updated.LogFile != "/tmp/gnatsd-2.log" {
t.Fatalf("LogFile is incorrect.\nexpected: /tmp/gnatsd-2.log\ngot: %s", updated.LogFile)
}
if !updated.Syslog {
t.Fatal("Expected Syslog to be true")
}
if updated.RemoteSyslog != "udp://localhost:514" {
t.Fatalf("RemoteSyslog is incorrect.\nexpected: udp://localhost:514\ngot: %s", updated.RemoteSyslog)
if runtime.GOOS != "windows" {
if updated.RemoteSyslog != "udp://localhost:514" {
t.Fatalf("RemoteSyslog is incorrect.\nexpected: udp://localhost:514\ngot: %s", updated.RemoteSyslog)
}
if updated.LogFile != "/tmp/gnatsd-2.log" {
t.Fatalf("LogFile is incorrect.\nexpected: /tmp/gnatsd-2.log\ngot: %s", updated.LogFile)
}
}
if updated.TLSConfig == nil {
t.Fatal("Expected TLSConfig to be non-nil")
@@ -1092,6 +1108,7 @@ func TestConfigReloadChangePermissions(t *testing.T) {
func TestConfigReloadClusterHostUnsupported(t *testing.T) {
server, _, config := newServerWithSymlinkConfig(t, "tmp.conf", "./configs/reload/srv_a_1.conf")
defer os.Remove(config)
defer server.Shutdown()
// Attempt to change cluster listen host.
if err := os.Remove(config); err != nil {
@@ -1112,6 +1129,7 @@ func TestConfigReloadClusterHostUnsupported(t *testing.T) {
func TestConfigReloadClusterPortUnsupported(t *testing.T) {
server, _, config := newServerWithSymlinkConfig(t, "tmp.conf", "./configs/reload/srv_a_1.conf")
defer os.Remove(config)
defer server.Shutdown()
// Attempt to change cluster listen port.
if err := os.Remove(config); err != nil {
@@ -1325,6 +1343,7 @@ func TestConfigReloadDisableClusterAuthorization(t *testing.T) {
func TestConfigReloadClusterRoutes(t *testing.T) {
srvb, srvbOpts, srvbConfig := runServerWithSymlinkConfig(t, "tmp_b.conf", "./configs/reload/srv_b_1.conf")
defer os.Remove(srvbConfig)
defer srvb.Shutdown()
srva, srvaOpts, srvaConfig := runServerWithSymlinkConfig(t, "tmp_a.conf", "./configs/reload/srv_a_1.conf")
defer os.Remove(srvaConfig)

View File

@@ -36,7 +36,6 @@ func TestRouteConfig(t *testing.T) {
NoAdvertise: true,
ConnectRetries: 2,
},
LogFile: "/tmp/nats_cluster_test.log",
PidFile: "/tmp/nats_cluster_test.pid",
}

View File

@@ -67,6 +67,7 @@ func TestSignalToReloadConfig(t *testing.T) {
if err != nil {
t.Fatalf("Error processing config file: %v", err)
}
opts.NoLog = true
s := RunServer(opts)
defer s.Shutdown()