Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make InfluxDB win32 friendly, fix unit test is failed on the windows and it is for connection refused. #2150

Merged
merged 1 commit into from
Apr 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/influxd/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func TestBackupCommand_ErrConnectionRefused(t *testing.T) {
// Execute the backup command.
path := tempfile()
defer os.Remove(path)
if err := NewBackupCommand().Run("-host", s.URL, path); err == nil || !strings.Contains(err.Error(), `connection refused`) {
if err := NewBackupCommand().Run("-host", s.URL, path); err == nil ||
!(strings.Contains(err.Error(), `connection refused`) || strings.Contains(err.Error(), `No connection could be made`)) {
t.Fatal(err)
}
}
Expand Down
10 changes: 7 additions & 3 deletions messaging/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func init() {
testDataURL, _ = url.Parse("http://localhost:1234/data")
}

func is_connection_refused(err error) bool {
return strings.Contains(err.Error(), `connection refused`) || strings.Contains(err.Error(), `No connection could be made`)
}

// Ensure a client can open the configuration file, if it exists.
func TestClient_Open_WithConfig(t *testing.T) {
// Write configuration file.
Expand Down Expand Up @@ -260,7 +264,7 @@ func TestClient_Publish_ErrConnectionRefused(t *testing.T) {
defer c.Close()

// Publish message to server.
if _, err := c.Publish(&messaging.Message{}); err == nil || !strings.Contains(err.Error(), `connection refused`) {
if _, err := c.Publish(&messaging.Message{}); err == nil || !is_connection_refused(err) {
t.Fatal(err)
}
}
Expand Down Expand Up @@ -361,7 +365,7 @@ func TestClient_Ping_ErrConnectionRefused(t *testing.T) {
defer c.Close()

// Ping server.
if err := c.Ping(); err == nil || !strings.Contains(err.Error(), `connection refused`) {
if err := c.Ping(); err == nil || !is_connection_refused(err) {
t.Fatal(err)
}
}
Expand Down Expand Up @@ -619,7 +623,7 @@ func TestConn_Heartbeat_ErrConnectionRefused(t *testing.T) {
// Create connection and heartbeat.
c := messaging.NewConn(0, testDataURL)
c.SetURL(*MustParseURL(s.URL))
if err := c.Heartbeat(); err == nil || !strings.Contains(err.Error(), `connection refused`) {
if err := c.Heartbeat(); err == nil || !is_connection_refused(err) {
t.Fatalf("unexpected error: %s", err)
}
}
Expand Down
14 changes: 9 additions & 5 deletions raft/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import (
"github.com/influxdb/influxdb/raft"
)

func is_connection_refused(err error) bool {
return strings.Contains(err.Error(), `connection refused`) || strings.Contains(err.Error(), `No connection could be made`)
}

// Ensure a join over HTTP can be read and responded to.
func TestHTTPTransport_Join(t *testing.T) {
// Start mock HTTP server.
Expand Down Expand Up @@ -49,7 +53,7 @@ func TestHTTPTransport_Join(t *testing.T) {
// Ensure that joining a server that doesn't exist returns an error.
func TestHTTPTransport_Join_ErrConnectionRefused(t *testing.T) {
_, _, _, err := (&raft.HTTPTransport{}).Join(url.URL{Scheme: "http", Host: "localhost:27322"}, url.URL{Host: "local"})
if err == nil || !strings.Contains(err.Error(), "connection refused") {
if err == nil || !is_connection_refused(err) {
t.Fatalf("unexpected error: %s", err)
}
}
Expand Down Expand Up @@ -144,7 +148,7 @@ func TestHTTPTransport_Leave(t *testing.T) {
// Ensure that leaving a server that doesn't exist returns an error.
func TestHTTPTransport_Leave_ErrConnectionRefused(t *testing.T) {
err := (&raft.HTTPTransport{}).Leave(url.URL{Scheme: "http", Host: "localhost:27322"}, 1)
if err == nil || !strings.Contains(err.Error(), "connection refused") {
if err == nil || !is_connection_refused(err) {
t.Fatalf("unexpected error: %s", err)
}
}
Expand Down Expand Up @@ -231,7 +235,7 @@ func TestHTTPTransport_Heartbeat_ErrConnectionRefused(t *testing.T) {
_, err := (&raft.HTTPTransport{}).Heartbeat(*u, 0, 0, 0)
if err == nil {
t.Fatal("expected error")
} else if !strings.Contains(err.Error(), `connection refused`) {
} else if !is_connection_refused(err) {
t.Fatalf("unexpected error: %s", err)
}
}
Expand Down Expand Up @@ -294,7 +298,7 @@ func TestHTTPTransport_ReadFrom_ErrConnectionRefused(t *testing.T) {
_, err := (&raft.HTTPTransport{}).ReadFrom(*u, 0, 0, 0)
if err == nil {
t.Fatal("expected error")
} else if !strings.Contains(err.Error(), `connection refused`) {
} else if !is_connection_refused(err) {
t.Fatalf("unexpected error: %s", err)
}
}
Expand Down Expand Up @@ -351,7 +355,7 @@ func TestHTTPTransport_RequestVote_ErrConnectionRefused(t *testing.T) {
u, _ := url.Parse("http://localhost:41932")
if err := (&raft.HTTPTransport{}).RequestVote(*u, 0, 0, 0, 0); err == nil {
t.Fatal("expected error")
} else if !strings.Contains(err.Error(), `connection refused`) {
} else if !is_connection_refused(err) {
t.Fatalf("unexpected error: %s", err)
}
}
Expand Down