@@ -29,7 +29,14 @@ func TestSessionStore(t *testing.T) {
2929}
3030
3131var _ = 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 {
35+ Close() error
36+ }
37+
3238 var mr *miniredis.Miniredis
39+ var ss sessionsapi.SessionStore
3340
3441 BeforeEach(func() {
3542 var err error
@@ -41,12 +48,25 @@ var _ = Describe("Redis SessionStore Tests", func() {
4148 mr.Close()
4249 })
4350
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())
56+ }
57+ }
58+ })
59+
4460 tests.RunSessionStoreTests(
4561 func(opts *options.SessionOptions, cookieOpts *options.CookieOptions) (sessionsapi.SessionStore, error) {
4662 // Set the connection URL
4763 opts.Type = options.RedisSessionStoreType
4864 opts.Redis.ConnectionURL = "redis://" + mr.Addr()
49− return NewRedisSessionStore(opts, cookieOpts)
65+
66+ // Capture the session store so that we can close the client
67+ var err error
68+ ss, err = NewRedisSessionStore(opts, cookieOpts)
69+ return ss, err
5070 },
5171 func(d time.Duration) error {
5272 mr.FastForward(d)
@@ -63,7 +83,7 @@ var _ = Describe("Redis SessionStore Tests", func() {
6383 })
6484
6585 AfterEach(func() {
66− go ms.Close()
86+ ms.Close()
6787 })
6888
6989 tests.RunSessionStoreTests(
@@ -74,7 +94,11 @@ var _ = Describe("Redis SessionStore Tests", func() {
7494 opts.Redis.SentinelConnectionURLs = []string{sentinelAddr}
7595 opts.Redis.UseSentinel = true
7696 opts.Redis.SentinelMasterName = ms.MasterInfo().Name
77− return NewRedisSessionStore(opts, cookieOpts)
97+
98+ // Capture the session store so that we can close the client
99+ var err error
100+ ss, err = NewRedisSessionStore(opts, cookieOpts)
101+ return ss, err
78102 },
79103 func(d time.Duration) error {
80104 mr.FastForward(d)
@@ -90,7 +114,11 @@ var _ = Describe("Redis SessionStore Tests", func() {
90114 opts.Type = options.RedisSessionStoreType
91115 opts.Redis.ClusterConnectionURLs = []string{clusterAddr}
92116 opts.Redis.UseCluster = true
93− return NewRedisSessionStore(opts, cookieOpts)
117+
118+ // Capture the session store so that we can close the client
119+ var err error
120+ ss, err = NewRedisSessionStore(opts, cookieOpts)
121+ return ss, err
94122 },
95123 func(d time.Duration) error {
96124 mr.FastForward(d)