-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
237 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ type Config struct { | |
Port string | ||
DB int | ||
ConnectionLimit int | ||
AllowSlaveReads bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package redis | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/moira-alert/moira/logging/go-logging" | ||
. "github.com/smartystreets/goconvey/convey" | ||
) | ||
|
||
var logger, _ = logging.ConfigureLog("stdout", "debug", "test") | ||
|
||
var sentinelConfig = SentinelPoolDialerConfig{ | ||
MasterName: "master01", | ||
DB: 0, | ||
DialTimeout: time.Millisecond, | ||
SentinelAddresses: []string{ | ||
"fake-sentinel:26379", | ||
}, | ||
} | ||
|
||
func TestDirectDialer(t *testing.T) { | ||
Convey("Direct dialer", t, func() { | ||
Convey("Tries dial and fails", func() { | ||
dialer := DirectPoolDialer { | ||
serverAddress: "fake-redis:6379", | ||
db: 0, | ||
dialTimeout: time.Millisecond, | ||
} | ||
|
||
_, err := dialer.Dial() | ||
|
||
So(err.Error(), ShouldEqual, "dial tcp: i/o timeout") | ||
}) | ||
|
||
Convey("Test dials successfully", func() { | ||
dialer := DirectPoolDialer { | ||
serverAddress: "localhost:6379", | ||
db: 0, | ||
dialTimeout: 5 * time.Second, | ||
} | ||
|
||
conn, err := dialer.Dial() | ||
|
||
So(err, ShouldBeNil) | ||
|
||
err = dialer.Test(conn, time.Now()) | ||
So(err, ShouldBeNil) | ||
}) | ||
}) | ||
} | ||
|
||
func TestSentinelDialer(t *testing.T) { | ||
dialer := NewSentinelPoolDialer(logger, sentinelConfig) | ||
|
||
Convey("Tries dial and fails", t, func() { | ||
_, err := dialer.Dial() | ||
So(err.Error(), ShouldEqual, "redigo: no sentinels available; last error: dial tcp: i/o timeout") | ||
}) | ||
} | ||
|
||
func TestSlaveDialer(t *testing.T) { | ||
dialer := NewSentinelPoolDialer(logger, sentinelConfig) | ||
slaveDialer := NewSentinelSlavePoolDialer(dialer) | ||
|
||
Convey("Tries dial and fails", t, func() { | ||
_, err := slaveDialer.Dial() | ||
So(err.Error(), ShouldEqual, "redigo: no sentinels available; last error: dial tcp: i/o timeout") | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters