tiny_tds 0.6.2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,95 @@
1
+ require 'test_helper'
2
+ require 'logger'
3
+ require 'benchmark'
4
+
5
+ class ThreadTest < TinyTds::TestCase
6
+
7
+ describe 'Threaded SELECT queries' do
8
+
9
+ before do
10
+ @logger = Logger.new $stdout
11
+ @logger.level = Logger::WARN
12
+ @poolsize = 4
13
+ @numthreads = 10
14
+ @query = "waitfor delay '00:00:01'"
15
+ @pool = ConnectionPool.new(:size => @poolsize, :timeout => 5) { new_connection }
16
+ end
17
+
18
+ it 'should finish faster in parallel' do
19
+ x = Benchmark.realtime do
20
+ threads = []
21
+ @numthreads.times do |i|
22
+ start = Time.new
23
+ threads << Thread.new do
24
+ ts = Time.new
25
+ @pool.with do |client|
26
+ result = client.execute @query
27
+ result.each { |r| puts r }
28
+ end
29
+ te = Time.new
30
+ @logger.info "Thread #{i} finished in #{te - ts} thread seconds, #{te - start} real seconds"
31
+ end
32
+ end
33
+ threads.each { |t| t.join }
34
+ end
35
+ assert x < @numthreads, "#{x} is not faster than #{@numthreads} seconds"
36
+ mintime = (1.0*@numthreads/@poolsize).ceil
37
+ @logger.info "#{@numthreads} queries on #{@poolsize} threads: #{x} sec. Minimum time: #{mintime} sec."
38
+ assert x > mintime, "#{x} is not slower than #{mintime} seconds"
39
+ end
40
+
41
+ it 'should not crash on error in parallel' do
42
+ threads = []
43
+ @numthreads.times do |i|
44
+ threads << Thread.new do
45
+ @pool.with do |client|
46
+ begin
47
+ result = client.execute "select dbname()"
48
+ result.each { |r| puts r }
49
+ rescue Exception => e
50
+ # We are throwing an error on purpose here since 0.6.1 would
51
+ # segfault on errors thrown in threads
52
+ end
53
+ end
54
+ end
55
+ end
56
+ threads.each { |t| t.join }
57
+ assert true
58
+ end
59
+
60
+ it 'should cancel when hitting timeout in thread' do
61
+ exception = false
62
+
63
+ thread = Thread.new do
64
+ @pool.with do |client|
65
+ begin
66
+ # The default query timeout is 5, so this will last longer than that
67
+ result = client.execute "waitfor delay '00:00:07'; select db_name()"
68
+ result.each { |r| puts r }
69
+ rescue TinyTds::Error => e
70
+ if e.message == 'Adaptive Server connection timed out'
71
+ exception = true
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ timer_thread = Thread.new do
78
+ # Sleep until after the timeout (of 5) should have been reached
79
+ sleep(6)
80
+ if not exception
81
+ thread.kill
82
+ raise "Timeout passed without query timing out"
83
+ end
84
+ end
85
+
86
+ thread.join
87
+ timer_thread.join
88
+
89
+ assert exception
90
+ end
91
+
92
+ end
93
+
94
+ end
95
+
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiny_tds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.2
5
+ platform: x64-mingw32
6
+ authors:
7
+ - Ken Collins
8
+ - Erik Bryn
9
+ - Will Bond
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2014-05-19 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: 0.9.2
29
+ - !ruby/object:Gem::Dependency
30
+ name: mini_portile
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 0.5.1
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: 0.5.1
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake-compiler
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: 0.9.1
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 0.9.1
57
+ - !ruby/object:Gem::Dependency
58
+ name: activesupport
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: '3.0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: '3.0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: minitest
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ - !ruby/object:Gem::Dependency
86
+ name: connection_pool
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: 0.9.2
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 0.9.2
99
+ description: TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library.
100
+ Developed for the ActiveRecord SQL Server adapter.
101
+ email:
102
+ - ken@metaskills.net
103
+ - will@wbond.net
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - .gitignore
109
+ - CHANGELOG
110
+ - Gemfile
111
+ - MIT-LICENSE
112
+ - README.md
113
+ - Rakefile
114
+ - compile/rake-compiler-dev-box.patch
115
+ - ext/patch/Makefile.in.diff
116
+ - ext/patch/dblib-30-char-username.diff
117
+ - ext/patch/sspi_w_kerberos.diff
118
+ - ext/tiny_tds/client.c
119
+ - ext/tiny_tds/client.h
120
+ - ext/tiny_tds/extconf.rb
121
+ - ext/tiny_tds/result.c
122
+ - ext/tiny_tds/result.h
123
+ - ext/tiny_tds/tiny_tds_ext.c
124
+ - ext/tiny_tds/tiny_tds_ext.h
125
+ - lib/tiny_tds.rb
126
+ - lib/tiny_tds/2.0/tiny_tds.so
127
+ - lib/tiny_tds/2.1/tiny_tds.so
128
+ - lib/tiny_tds/client.rb
129
+ - lib/tiny_tds/error.rb
130
+ - lib/tiny_tds/result.rb
131
+ - lib/tiny_tds/version.rb
132
+ - tasks/ports.rake
133
+ - test/benchmark/query.rb
134
+ - test/benchmark/query_odbc.rb
135
+ - test/benchmark/query_tinytds.rb
136
+ - test/client_test.rb
137
+ - test/result_test.rb
138
+ - test/schema/1px.gif
139
+ - test/schema/sqlserver_2000.sql
140
+ - test/schema/sqlserver_2005.sql
141
+ - test/schema/sqlserver_2008.sql
142
+ - test/schema/sqlserver_azure.sql
143
+ - test/schema/sybase_ase.sql
144
+ - test/schema_test.rb
145
+ - test/test_helper.rb
146
+ - test/thread_test.rb
147
+ homepage: http://github.com/rails-sqlserver/tiny_tds
148
+ licenses: []
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options:
152
+ - --charset=UTF-8
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.2.2
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library.
171
+ test_files: []