File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,22 @@ def connect *args
104
104
ssl_client . close
105
105
end
106
106
107
+ it "should not leave dangling connections after garbage collection" do
108
+ GC . start
109
+ client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] )
110
+ before_count = client . query ( "SHOW STATUS LIKE 'Threads_connected'" ) . first [ 'Value' ] . to_i
111
+
112
+ 10 . times do
113
+ Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] ) . query ( 'SELECT 1' )
114
+ end
115
+ after_count = client . query ( "SHOW STATUS LIKE 'Threads_connected'" ) . first [ 'Value' ] . to_i
116
+ after_count . should == before_count + 10
117
+
118
+ GC . start
119
+ final_count = client . query ( "SHOW STATUS LIKE 'Threads_connected'" ) . first [ 'Value' ] . to_i
120
+ final_count . should == before_count
121
+ end
122
+
107
123
it "should be able to connect to database with numeric-only name" do
108
124
lambda {
109
125
creds = DatabaseCredentials [ 'numericuser' ]
You can’t perform that action at this time.
0 commit comments