@@ -29,7 +29,14 @@ func TestSessionStore(t *testing.T) {
31var _ = Describe("Redis SessionStore Tests", func() {
31var _ = Describe("Redis SessionStore Tests", func() {
32+ // helper interface to allow us to close client connections
33+ // All non-nil redis clients should implement this
34+ type closer interface {
32 var mr *miniredis.Miniredis
38 var mr *miniredis.Miniredis
39+ var ss sessionsapi.SessionStore
34 BeforeEach(func() {
41 BeforeEach(func() {
35 var err error
42 var err error
@@ -41,12 +48,25 @@ var _ = Describe("Redis SessionStore Tests", func() {
41 mr.Close()
48 mr.Close()
51+ JustAfterEach(func() {
52+ // Release any connections immediately after the test ends
53+ if redisStore, ok := ss.(*SessionStore); ok {
54+ if redisStore.Client != nil {
55+ Expect(redisStore.Client.(closer).Close()).To(Succeed())
44 tests.RunSessionStoreTests(
60 tests.RunSessionStoreTests(
45 func(opts *options.SessionOptions, cookieOpts *options.CookieOptions) (sessionsapi.SessionStore, error) {
61 func(opts *options.SessionOptions, cookieOpts *options.CookieOptions) (sessionsapi.SessionStore, error) {
46 // Set the connection URL
62 // Set the connection URL
47 opts.Type = options.RedisSessionStoreType
63 opts.Type = options.RedisSessionStoreType
48 opts.Redis.ConnectionURL = "redis://" + mr.Addr()
64 opts.Redis.ConnectionURL = "redis://" + mr.Addr()
66+ // Capture the session store so that we can close the client
49− return NewRedisSessionStore(opts, cookieOpts)
68+ ss, err = NewRedisSessionStore(opts, cookieOpts)
51 func(d time.Duration) error {
71 func(d time.Duration) error {
52 mr.FastForward(d)
72 mr.FastForward(d)
@@ -63,7 +83,7 @@ var _ = Describe("Redis SessionStore Tests", func() {
65 AfterEach(func() {
85 AfterEach(func() {
66− go ms.Close()
86+ ms.Close()
69 tests.RunSessionStoreTests(
89 tests.RunSessionStoreTests(
@@ -74,7 +94,11 @@ var _ = Describe("Redis SessionStore Tests", func() {
74 opts.Redis.SentinelConnectionURLs = []string{sentinelAddr}
94 opts.Redis.SentinelConnectionURLs = []string{sentinelAddr}
75 opts.Redis.UseSentinel = true
95 opts.Redis.UseSentinel = true
76 opts.Redis.SentinelMasterName = ms.MasterInfo().Name
96 opts.Redis.SentinelMasterName = ms.MasterInfo().Name
98+ // Capture the session store so that we can close the client
77− return NewRedisSessionStore(opts, cookieOpts)
100+ ss, err = NewRedisSessionStore(opts, cookieOpts)
79 func(d time.Duration) error {
103 func(d time.Duration) error {
80 mr.FastForward(d)
104 mr.FastForward(d)
@@ -90,7 +114,11 @@ var _ = Describe("Redis SessionStore Tests", func() {
90 opts.Type = options.RedisSessionStoreType
114 opts.Type = options.RedisSessionStoreType
91 opts.Redis.ClusterConnectionURLs = []string{clusterAddr}
115 opts.Redis.ClusterConnectionURLs = []string{clusterAddr}
92 opts.Redis.UseCluster = true
116 opts.Redis.UseCluster = true
118+ // Capture the session store so that we can close the client
93− return NewRedisSessionStore(opts, cookieOpts)
120+ ss, err = NewRedisSessionStore(opts, cookieOpts)
95 func(d time.Duration) error {
123 func(d time.Duration) error {
96 mr.FastForward(d)
124 mr.FastForward(d)