tiny_tds 2.1.4-x86-mingw32 → 2.1.6-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +407 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +12 -2
- data/Gemfile +0 -7
- data/README.md +2 -4
- data/Rakefile +19 -10
- data/VERSION +1 -1
- data/docker-compose.yml +19 -7
- data/ext/tiny_tds/client.c +6 -3
- data/ext/tiny_tds/extconf.rb +21 -2
- data/ext/tiny_tds/extconsts.rb +1 -1
- data/ext/tiny_tds/result.c +5 -2
- data/lib/tiny_tds/2.4/tiny_tds.so +0 -0
- data/lib/tiny_tds/2.5/tiny_tds.so +0 -0
- data/lib/tiny_tds/2.6/tiny_tds.so +0 -0
- data/lib/tiny_tds/2.7/tiny_tds.so +0 -0
- data/lib/tiny_tds/3.0/tiny_tds.so +0 -0
- data/lib/tiny_tds/gem.rb +1 -6
- data/ports/x86-mingw32/freetds/1.1.24/bin/bsqldb.exe +0 -0
- data/ports/x86-mingw32/freetds/1.1.24/bin/datacopy.exe +0 -0
- data/ports/x86-mingw32/freetds/1.1.24/bin/defncopy.exe +0 -0
- data/ports/x86-mingw32/freetds/1.1.24/bin/freebcp.exe +0 -0
- data/ports/x86-mingw32/freetds/1.1.24/bin/libct-4.dll +0 -0
- data/ports/x86-mingw32/freetds/1.1.24/bin/libsybdb-5.dll +0 -0
- data/ports/x86-mingw32/freetds/1.1.24/bin/tdspool.exe +0 -0
- data/ports/x86-mingw32/freetds/1.1.24/bin/tsql.exe +0 -0
- data/ports/{i686-w64-mingw32 → x86-mingw32}/freetds/1.1.24/lib/libct.dll.a +0 -0
- data/ports/{i686-w64-mingw32 → x86-mingw32}/freetds/1.1.24/lib/libct.la +2 -2
- data/ports/{i686-w64-mingw32 → x86-mingw32}/freetds/1.1.24/lib/libsybdb.dll.a +0 -0
- data/ports/{i686-w64-mingw32 → x86-mingw32}/freetds/1.1.24/lib/libsybdb.la +2 -2
- data/ports/x86-mingw32/libiconv/1.15/bin/iconv.exe +0 -0
- data/ports/x86-mingw32/libiconv/1.15/bin/libcharset-1.dll +0 -0
- data/ports/{i686-w64-mingw32 → x86-mingw32}/libiconv/1.15/bin/libiconv-2.dll +0 -0
- data/ports/{i686-w64-mingw32 → x86-mingw32}/libiconv/1.15/lib/libcharset.dll.a +0 -0
- data/ports/{i686-w64-mingw32 → x86-mingw32}/libiconv/1.15/lib/libcharset.la +2 -2
- data/ports/{i686-w64-mingw32 → x86-mingw32}/libiconv/1.15/lib/libiconv.dll.a +0 -0
- data/ports/{i686-w64-mingw32 → x86-mingw32}/libiconv/1.15/lib/libiconv.la +2 -2
- data/ports/x86-mingw32/openssl/1.1.1s/bin/c_rehash +251 -0
- data/ports/x86-mingw32/openssl/1.1.1s/bin/libcrypto-1_1.dll +0 -0
- data/ports/x86-mingw32/openssl/1.1.1s/bin/libssl-1_1.dll +0 -0
- data/ports/x86-mingw32/openssl/1.1.1s/bin/openssl.exe +0 -0
- data/ports/x86-mingw32/openssl/1.1.1s/lib/libcrypto.a +0 -0
- data/ports/{i686-w64-mingw32/openssl/1.1.1d → x86-mingw32/openssl/1.1.1s}/lib/libcrypto.dll.a +0 -0
- data/ports/x86-mingw32/openssl/1.1.1s/lib/libssl.a +0 -0
- data/ports/{i686-w64-mingw32/openssl/1.1.1d → x86-mingw32/openssl/1.1.1s}/lib/libssl.dll.a +0 -0
- data/setup_cimgruby_dev.sh +25 -0
- data/start_dev.sh +21 -0
- data/tasks/native_gem.rake +15 -6
- data/tasks/ports/libiconv.rb +0 -17
- data/tasks/ports/recipe.rb +16 -4
- data/tasks/ports.rake +58 -35
- data/test/bin/install-mssql.ps1 +31 -0
- data/test/bin/install-mssqltools.sh +9 -0
- data/test/bin/setup_tinytds_db.sh +7 -0
- data/test/bin/setup_volume_permissions.sh +10 -0
- data/test/client_test.rb +22 -4
- data/test/gem_test.rb +11 -13
- data/test/sql/db-create.sql +18 -0
- data/test/sql/db-login.sql +38 -0
- data/test/test_helper.rb +16 -7
- data/tiny_tds.gemspec +7 -6
- metadata +69 -50
- data/.travis.yml +0 -25
- data/appveyor.yml +0 -72
- data/ports/i686-w64-mingw32/freetds/1.1.24/bin/bsqldb.exe +0 -0
- data/ports/i686-w64-mingw32/freetds/1.1.24/bin/datacopy.exe +0 -0
- data/ports/i686-w64-mingw32/freetds/1.1.24/bin/defncopy.exe +0 -0
- data/ports/i686-w64-mingw32/freetds/1.1.24/bin/freebcp.exe +0 -0
- data/ports/i686-w64-mingw32/freetds/1.1.24/bin/libct-4.dll +0 -0
- data/ports/i686-w64-mingw32/freetds/1.1.24/bin/libsybdb-5.dll +0 -0
- data/ports/i686-w64-mingw32/freetds/1.1.24/bin/tdspool.exe +0 -0
- data/ports/i686-w64-mingw32/freetds/1.1.24/bin/tsql.exe +0 -0
- data/ports/i686-w64-mingw32/libiconv/1.15/bin/iconv.exe +0 -0
- data/ports/i686-w64-mingw32/libiconv/1.15/bin/libcharset-1.dll +0 -0
- data/ports/i686-w64-mingw32/openssl/1.1.1d/bin/c_rehash +0 -232
- data/ports/i686-w64-mingw32/openssl/1.1.1d/bin/libcrypto-1_1.dll +0 -0
- data/ports/i686-w64-mingw32/openssl/1.1.1d/bin/libssl-1_1.dll +0 -0
- data/ports/i686-w64-mingw32/openssl/1.1.1d/bin/openssl.exe +0 -0
- data/ports/i686-w64-mingw32/openssl/1.1.1d/lib/libcrypto.a +0 -0
- data/ports/i686-w64-mingw32/openssl/1.1.1d/lib/libssl.a +0 -0
- data/test/appveyor/dbsetup.ps1 +0 -27
- data/test/appveyor/dbsetup.sql +0 -9
- data/test/bin/setup.sh +0 -19
- /data/ports/{i686-w64-mingw32 → x86-mingw32}/freetds/1.1.24/bin/osql +0 -0
- /data/ports/{i686-w64-mingw32 → x86-mingw32}/libiconv/1.15/lib/charset.alias +0 -0
data/tasks/ports.rake
CHANGED
@@ -7,63 +7,69 @@ require_relative 'ports/freetds'
|
|
7
7
|
require_relative '../ext/tiny_tds/extconsts'
|
8
8
|
|
9
9
|
namespace :ports do
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
libraries_to_compile = {
|
11
|
+
openssl: Ports::Openssl.new(OPENSSL_VERSION),
|
12
|
+
libiconv: Ports::Libiconv.new(ICONV_VERSION),
|
13
|
+
freetds: Ports::Freetds.new(FREETDS_VERSION)
|
14
|
+
}
|
13
15
|
|
14
16
|
directory "ports"
|
15
|
-
CLEAN.include "ports/*
|
17
|
+
CLEAN.include "ports/*mingw*"
|
16
18
|
CLEAN.include "ports/*.installed"
|
17
19
|
|
18
|
-
task :openssl, [:host] do |
|
19
|
-
args.with_defaults(host: RbConfig::CONFIG['host'])
|
20
|
+
task :openssl, [:host, :gem_platform] do |_task, args|
|
21
|
+
args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
|
20
22
|
|
21
|
-
openssl.files = [OPENSSL_SOURCE_URI]
|
22
|
-
openssl.host = args.host
|
23
|
-
openssl.
|
24
|
-
|
23
|
+
libraries_to_compile[:openssl].files = [OPENSSL_SOURCE_URI]
|
24
|
+
libraries_to_compile[:openssl].host = args.host
|
25
|
+
libraries_to_compile[:openssl].gem_platform = args.gem_platform
|
26
|
+
|
27
|
+
libraries_to_compile[:openssl].cook
|
28
|
+
libraries_to_compile[:openssl].activate
|
25
29
|
end
|
26
30
|
|
27
|
-
task :libiconv, [:host] do |
|
28
|
-
args.with_defaults(host: RbConfig::CONFIG['host'])
|
31
|
+
task :libiconv, [:host, :gem_platform] do |_task, args|
|
32
|
+
args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
|
29
33
|
|
30
|
-
libiconv.files = [ICONV_SOURCE_URI]
|
31
|
-
libiconv.host = args.host
|
32
|
-
libiconv.
|
33
|
-
libiconv.
|
34
|
+
libraries_to_compile[:libiconv].files = [ICONV_SOURCE_URI]
|
35
|
+
libraries_to_compile[:libiconv].host = args.host
|
36
|
+
libraries_to_compile[:libiconv].gem_platform = args.gem_platform
|
37
|
+
libraries_to_compile[:libiconv].cook
|
38
|
+
libraries_to_compile[:libiconv].activate
|
34
39
|
end
|
35
40
|
|
36
|
-
task :freetds, [:host] do |
|
37
|
-
args.with_defaults(host: RbConfig::CONFIG['host'])
|
41
|
+
task :freetds, [:host, :gem_platform] do |_task, args|
|
42
|
+
args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
|
38
43
|
|
39
|
-
freetds.files = [FREETDS_SOURCE_URI]
|
40
|
-
freetds.host = args.host
|
44
|
+
libraries_to_compile[:freetds].files = [FREETDS_SOURCE_URI]
|
45
|
+
libraries_to_compile[:freetds].host = args.host
|
46
|
+
libraries_to_compile[:freetds].gem_platform = args.gem_platform
|
41
47
|
|
42
|
-
if openssl
|
48
|
+
if libraries_to_compile[:openssl]
|
43
49
|
# freetds doesn't have an option that will provide an rpath
|
44
50
|
# so we do it manually
|
45
|
-
ENV['OPENSSL_CFLAGS'] = "-Wl,-rpath -Wl,#{openssl.path}/lib"
|
51
|
+
ENV['OPENSSL_CFLAGS'] = "-Wl,-rpath -Wl,#{libraries_to_compile[:openssl].path}/lib"
|
46
52
|
# Add the pkgconfig file with MSYS2'ish path, to prefer our ports build
|
47
53
|
# over MSYS2 system OpenSSL.
|
48
|
-
ENV['PKG_CONFIG_PATH'] = "#{openssl.path.gsub(/^(\w):/i){"/"
|
49
|
-
freetds.configure_options << "--with-openssl=#{openssl.path}"
|
54
|
+
ENV['PKG_CONFIG_PATH'] = "#{libraries_to_compile[:openssl].path.gsub(/^(\w):/i) { "/" + $1.downcase }}/lib/pkgconfig:#{ENV['PKG_CONFIG_PATH']}"
|
55
|
+
libraries_to_compile[:freetds].configure_options << "--with-openssl=#{libraries_to_compile[:openssl].path}"
|
50
56
|
end
|
51
57
|
|
52
|
-
if libiconv
|
53
|
-
freetds.configure_options << "--with-libiconv-prefix=#{libiconv.path}"
|
58
|
+
if libraries_to_compile[:libiconv]
|
59
|
+
libraries_to_compile[:freetds].configure_options << "--with-libiconv-prefix=#{libraries_to_compile[:libiconv].path}"
|
54
60
|
end
|
55
61
|
|
56
|
-
freetds.cook
|
57
|
-
freetds.activate
|
62
|
+
libraries_to_compile[:freetds].cook
|
63
|
+
libraries_to_compile[:freetds].activate
|
58
64
|
end
|
59
65
|
|
60
|
-
task :compile, [:host] do |
|
61
|
-
args.with_defaults(host: RbConfig::CONFIG['host'])
|
66
|
+
task :compile, [:host, :gem_platform] do |_task, args|
|
67
|
+
args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
|
62
68
|
|
63
|
-
puts "Compiling ports for #{args.host}..."
|
69
|
+
puts "Compiling ports for #{args.host} (Ruby platform #{args.gem_platform}) ..."
|
64
70
|
|
65
|
-
|
66
|
-
Rake::Task["ports:#{lib}"].invoke(args.host)
|
71
|
+
libraries_to_compile.keys.each do |lib|
|
72
|
+
Rake::Task["ports:#{lib}"].invoke(args.host, args.gem_platform)
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
@@ -72,13 +78,30 @@ namespace :ports do
|
|
72
78
|
require 'rake_compiler_dock'
|
73
79
|
|
74
80
|
# build the ports for all our cross compile hosts
|
75
|
-
GEM_PLATFORM_HOSTS.each do |gem_platform,
|
81
|
+
GEM_PLATFORM_HOSTS.each do |gem_platform, meta|
|
76
82
|
# make sure to install our bundle
|
77
83
|
build = ['bundle']
|
78
|
-
build << "rake ports:compile[#{host}] MAKE='make -j`nproc`'"
|
84
|
+
build << "RUBY_CC_VERSION=#{meta[:ruby_versions]} rake ports:compile[#{meta[:host]},#{gem_platform}] MAKE='make -j`nproc`'"
|
79
85
|
RakeCompilerDock.sh build.join(' && '), platform: gem_platform
|
80
86
|
end
|
81
87
|
end
|
88
|
+
|
89
|
+
desc "Notes the actual versions for the compiled ports into a file"
|
90
|
+
task "version_file", [:gem_platform] do |_task, args|
|
91
|
+
args.with_defaults(gem_platform: RbConfig::CONFIG["arch"])
|
92
|
+
|
93
|
+
ports_version = {}
|
94
|
+
|
95
|
+
libraries_to_compile.each do |library, library_recipe|
|
96
|
+
ports_version[library] = library_recipe.version
|
97
|
+
end
|
98
|
+
|
99
|
+
ports_version[:platform] = args.gem_platform
|
100
|
+
|
101
|
+
File.open(".ports_versions", "w") do |f|
|
102
|
+
f.write ports_version
|
103
|
+
end
|
104
|
+
end
|
82
105
|
end
|
83
106
|
|
84
107
|
desc 'Build ports and activate libraries for the current architecture.'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
$ProgressPreference = 'SilentlyContinue'
|
2
|
+
|
3
|
+
if (-not(Test-path "C:\Downloads"))
|
4
|
+
{
|
5
|
+
mkdir "C:\Downloads"
|
6
|
+
}
|
7
|
+
|
8
|
+
$sqlInstallationFile = "C:\Downloads\sqlexpress.exe"
|
9
|
+
if (-not(Test-path $sqlInstallationFile -PathType leaf))
|
10
|
+
{
|
11
|
+
Write-Host "Downloading SQL Express ..."
|
12
|
+
Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=829176" -OutFile "C:\Downloads\sqlexpress.exe"
|
13
|
+
}
|
14
|
+
|
15
|
+
Write-Host "Installing SQL Express ..."
|
16
|
+
Start-Process -Wait -FilePath "C:\Downloads\sqlexpress.exe" -ArgumentList /qs, /x:"C:\Downloads\setup"
|
17
|
+
C:\Downloads\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS
|
18
|
+
|
19
|
+
Write-Host "Configuring SQL Express ..."
|
20
|
+
stop-service MSSQL`$SQLEXPRESS
|
21
|
+
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value ''
|
22
|
+
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433
|
23
|
+
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2
|
24
|
+
|
25
|
+
Write-Host "Starting SQL Express ..."
|
26
|
+
start-service MSSQL`$SQLEXPRESS
|
27
|
+
|
28
|
+
Write-Host "Configuring MSSQL for TinyTDS ..."
|
29
|
+
& sqlcmd -Q "CREATE DATABASE [tinytdstest];"
|
30
|
+
& sqlcmd -Q "CREATE LOGIN [tinytds] WITH PASSWORD = '', CHECK_POLICY = OFF, DEFAULT_DATABASE = [tinytdstest];"
|
31
|
+
& sqlcmd -Q "USE [tinytdstest]; CREATE USER [tinytds] FOR LOGIN [tinytds]; EXEC sp_addrolemember N'db_owner', N'tinytds';"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -x
|
4
|
+
set -e
|
5
|
+
|
6
|
+
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
|
7
|
+
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
|
8
|
+
sudo apt-get update
|
9
|
+
sudo ACCEPT_EULA=Y apt-get -y install mssql-tools unixodbc-dev
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -x
|
4
|
+
|
5
|
+
sudo groupadd -g 3434 circleci_tinytds
|
6
|
+
sudo usermod -a -G circleci_tinytds $USER
|
7
|
+
sudo useradd circleci_tinytds -u 3434 -g 3434
|
8
|
+
sudo usermod -a -G circleci_tinytds circleci_tinytds
|
9
|
+
sudo chgrp -R circleci_tinytds .
|
10
|
+
sudo chmod -R g+rwx .
|
data/test/client_test.rb
CHANGED
@@ -16,6 +16,7 @@ class ClientTest < TinyTds::TestCase
|
|
16
16
|
assert @client.close
|
17
17
|
assert @client.closed?
|
18
18
|
assert !@client.active?
|
19
|
+
assert @client.dead?
|
19
20
|
action = lambda { @client.execute('SELECT 1 as [one]').each }
|
20
21
|
assert_raise_tinytds_error(action) do |e|
|
21
22
|
assert_match %r{closed connection}i, e.message, 'ignore if non-english test run'
|
@@ -133,9 +134,8 @@ class ClientTest < TinyTds::TestCase
|
|
133
134
|
end
|
134
135
|
|
135
136
|
it 'raises TinyTds exception with tcp socket network failure' do
|
136
|
-
skip if ENV['CI'] && ENV['APPVEYOR_BUILD_FOLDER'] # only CI using docker
|
137
137
|
begin
|
138
|
-
client = new_connection timeout: 2, port: 1234
|
138
|
+
client = new_connection timeout: 2, port: 1234, host: ENV['TOXIPROXY_HOST']
|
139
139
|
assert_client_works(client)
|
140
140
|
action = lambda { client.execute("waitfor delay '00:00:05'").do }
|
141
141
|
|
@@ -155,9 +155,10 @@ class ClientTest < TinyTds::TestCase
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'raises TinyTds exception with dead connection network failure' do
|
158
|
-
skip if
|
158
|
+
skip if ruby_windows?
|
159
|
+
|
159
160
|
begin
|
160
|
-
client = new_connection timeout: 2, port: 1234
|
161
|
+
client = new_connection timeout: 2, port: 1234, host: ENV['TOXIPROXY_HOST']
|
161
162
|
assert_client_works(client)
|
162
163
|
action = lambda { client.execute("waitfor delay '00:00:05'").do }
|
163
164
|
|
@@ -176,6 +177,23 @@ class ClientTest < TinyTds::TestCase
|
|
176
177
|
end
|
177
178
|
end
|
178
179
|
|
180
|
+
it 'raises TinyTds exception with login timeout' do
|
181
|
+
begin
|
182
|
+
action = lambda do
|
183
|
+
Toxiproxy[:sqlserver_test].toxic(:timeout, timeout: 0).apply do
|
184
|
+
new_connection login_timeout: 1, port: 1234, host: ENV['TOXIPROXY_HOST']
|
185
|
+
end
|
186
|
+
end
|
187
|
+
assert_raise_tinytds_error(action) do |e|
|
188
|
+
assert_equal 20003, e.db_error_number
|
189
|
+
assert_equal 6, e.severity
|
190
|
+
assert_match %r{timed out}i, e.message, 'ignore if non-english test run'
|
191
|
+
end
|
192
|
+
ensure
|
193
|
+
assert_new_connections_work
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
179
197
|
it 'raises TinyTds exception with wrong :username' do
|
180
198
|
skip if ENV['CI'] && sqlserver_azure? # Some issue with db_error_number.
|
181
199
|
options = connection_options :username => 'willnotwork'
|
data/test/gem_test.rb
CHANGED
@@ -9,11 +9,11 @@ class GemTest < MiniTest::Spec
|
|
9
9
|
|
10
10
|
# We're going to muck with some system globals so lets make sure
|
11
11
|
# they get set back later
|
12
|
-
|
12
|
+
original_platform = RbConfig::CONFIG['arch']
|
13
13
|
original_pwd = Dir.pwd
|
14
14
|
|
15
15
|
after do
|
16
|
-
RbConfig::CONFIG['
|
16
|
+
RbConfig::CONFIG['arch'] = original_platform
|
17
17
|
Dir.chdir original_pwd
|
18
18
|
end
|
19
19
|
|
@@ -61,7 +61,7 @@ class GemTest < MiniTest::Spec
|
|
61
61
|
end
|
62
62
|
|
63
63
|
before do
|
64
|
-
RbConfig::CONFIG['
|
64
|
+
RbConfig::CONFIG['arch'] = 'fake-host-with-dirs'
|
65
65
|
fake_bin_paths.each do |path|
|
66
66
|
FileUtils.mkdir_p(path)
|
67
67
|
end
|
@@ -85,7 +85,7 @@ class GemTest < MiniTest::Spec
|
|
85
85
|
|
86
86
|
describe 'when the ports directories are missing' do
|
87
87
|
before do
|
88
|
-
RbConfig::CONFIG['
|
88
|
+
RbConfig::CONFIG['arch'] = 'fake-host-without-dirs'
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should return no directories' do
|
@@ -115,7 +115,7 @@ class GemTest < MiniTest::Spec
|
|
115
115
|
end
|
116
116
|
|
117
117
|
before do
|
118
|
-
RbConfig::CONFIG['
|
118
|
+
RbConfig::CONFIG['arch'] = 'fake-host-with-dirs'
|
119
119
|
fake_lib_paths.each do |path|
|
120
120
|
FileUtils.mkdir_p(path)
|
121
121
|
end
|
@@ -139,7 +139,7 @@ class GemTest < MiniTest::Spec
|
|
139
139
|
|
140
140
|
describe 'when the ports directories are missing' do
|
141
141
|
before do
|
142
|
-
RbConfig::CONFIG['
|
142
|
+
RbConfig::CONFIG['arch'] = 'fake-host-without-dirs'
|
143
143
|
end
|
144
144
|
|
145
145
|
|
@@ -156,16 +156,14 @@ class GemTest < MiniTest::Spec
|
|
156
156
|
|
157
157
|
describe '#ports_host' do
|
158
158
|
{
|
159
|
-
'
|
160
|
-
'
|
161
|
-
'
|
162
|
-
'x86_64-
|
163
|
-
# consolidate this host to our build w64-mingw32 arch
|
164
|
-
'i686-pc-mingw32' => 'i686-w64-mingw32'
|
159
|
+
'x64-mingw-ucrt' => 'x64-mingw-ucrt',
|
160
|
+
'x64-mingw32' => 'x64-mingw32',
|
161
|
+
'x86-mingw32' => 'x86-mingw32',
|
162
|
+
'x86_64-linux' => 'x86_64-linux',
|
165
163
|
}.each do |host,expected|
|
166
164
|
describe "on a #{host} architecture" do
|
167
165
|
before do
|
168
|
-
RbConfig::CONFIG['
|
166
|
+
RbConfig::CONFIG['arch'] = host
|
169
167
|
end
|
170
168
|
|
171
169
|
it "should return a #{expected} ports host" do
|
@@ -0,0 +1,18 @@
|
|
1
|
+
:ON ERROR EXIT
|
2
|
+
|
3
|
+
PRINT 'RUNNING DB-CREATE.SQL, CREATING TINYTDS TEST DATABASE';
|
4
|
+
IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = 'tinytdstest')
|
5
|
+
BEGIN
|
6
|
+
CREATE DATABASE [tinytdstest];
|
7
|
+
END
|
8
|
+
GO
|
9
|
+
|
10
|
+
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name LIKE 'tinytdstest')
|
11
|
+
BEGIN
|
12
|
+
PRINT 'TINY TDS TEST DB SUCCESSFULY CREATED';
|
13
|
+
END
|
14
|
+
ELSE
|
15
|
+
BEGIN
|
16
|
+
THROW 51000, 'TINY TDS TEST DB CREATION FAILED', 1;
|
17
|
+
END
|
18
|
+
GO
|
@@ -0,0 +1,38 @@
|
|
1
|
+
:ON ERROR EXIT
|
2
|
+
|
3
|
+
PRINT 'RUNNING DB-LOGIN.SQL';
|
4
|
+
|
5
|
+
PRINT 'CREATING TINYTDS TEST LOGIN';
|
6
|
+
IF NOT EXISTS (select name from sys.server_principals where name like 'tinytds')
|
7
|
+
BEGIN
|
8
|
+
CREATE LOGIN [tinytds] WITH PASSWORD = '', CHECK_POLICY = OFF, DEFAULT_DATABASE = [tinytdstest];
|
9
|
+
END
|
10
|
+
GO
|
11
|
+
|
12
|
+
IF EXISTS (select name from sys.server_principals where name like 'tinytds')
|
13
|
+
BEGIN
|
14
|
+
PRINT 'TINY TDS TEST LOGIN SUCCESSFULY CREATED';
|
15
|
+
END
|
16
|
+
ELSE
|
17
|
+
BEGIN
|
18
|
+
THROW 51000, 'TINY TDS TEST LOGIN CREATION FAILED', 1;
|
19
|
+
END
|
20
|
+
GO
|
21
|
+
|
22
|
+
USE [tinytdstest];
|
23
|
+
IF NOT EXISTS (select name from sys.database_principals where name LIKE 'tinytds')
|
24
|
+
BEGIN
|
25
|
+
CREATE USER [tinytds] FOR LOGIN [tinytds];
|
26
|
+
EXEC sp_addrolemember N'db_owner', N'tinytds';
|
27
|
+
END
|
28
|
+
GO
|
29
|
+
|
30
|
+
IF EXISTS (select name from sys.database_principals where name LIKE 'tinytds')
|
31
|
+
BEGIN
|
32
|
+
PRINT 'TINY TDS TEST USER SUCCESSFULY CREATED';
|
33
|
+
END
|
34
|
+
ELSE
|
35
|
+
BEGIN
|
36
|
+
THROW 51000, 'TINY TDS TEST USER CREATION FAILED', 1;
|
37
|
+
END
|
38
|
+
GO
|
data/test/test_helper.rb
CHANGED
@@ -248,22 +248,31 @@ module TinyTds
|
|
248
248
|
end
|
249
249
|
|
250
250
|
def init_toxiproxy
|
251
|
-
return if ENV['APPVEYOR_BUILD_FOLDER'] # only for CI using docker
|
252
|
-
|
253
251
|
# In order for toxiproxy to work for local docker instances of mssql, the containers must be on the same network
|
254
252
|
# and the host used below must match the mssql container name so toxiproxy knows where to proxy to.
|
255
253
|
# localhost from the perspective of toxiproxy's container is its own container an *not* the mssql container it needs to proxy to.
|
256
254
|
# docker-compose.yml handles this automatically for us. In instances where someone is using their own local mssql container they'll
|
257
255
|
# need to set up the networks manually and set TINYTDS_UNIT_HOST to their mssql container name
|
258
256
|
# For anything other than localhost just use the environment config
|
259
|
-
|
260
|
-
|
261
|
-
|
257
|
+
toxi_host = ENV['TOXIPROXY_HOST'] || 'localhost'
|
258
|
+
toxi_api_port = 8474
|
259
|
+
toxi_test_port = 1234
|
260
|
+
Toxiproxy.host = "http://#{toxi_host}:#{toxi_api_port}"
|
261
|
+
|
262
|
+
toxi_upstream_host = ENV['TINYTDS_UNIT_HOST_TEST'] || ENV['TINYTDS_UNIT_HOST'] || 'localhost'
|
263
|
+
toxi_upstream_port = ENV['TINYTDS_UNIT_PORT'] || 1433
|
264
|
+
|
265
|
+
puts "\n-------------------------"
|
266
|
+
puts "Toxiproxy api listener: #{toxi_host}:#{toxi_api_port}"
|
267
|
+
puts "Toxiproxy unit test listener: #{toxi_host}:#{toxi_test_port}"
|
268
|
+
puts "Toxiproxy upstream sqlserver: #{toxi_upstream_host}:#{toxi_upstream_port}"
|
269
|
+
puts '-------------------------'
|
270
|
+
|
262
271
|
Toxiproxy.populate([
|
263
272
|
{
|
264
273
|
name: "sqlserver_test",
|
265
|
-
listen: "
|
266
|
-
upstream: "#{
|
274
|
+
listen: "#{toxi_host}:#{toxi_test_port}",
|
275
|
+
upstream: "#{toxi_upstream_host}:#{toxi_upstream_port}"
|
267
276
|
}
|
268
277
|
])
|
269
278
|
end
|
data/tiny_tds.gemspec
CHANGED
@@ -20,11 +20,12 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.license = 'MIT'
|
21
21
|
s.required_ruby_version = '>= 2.0.0'
|
22
22
|
s.metadata['msys2_mingw_dependencies'] = 'freetds'
|
23
|
-
s.add_development_dependency 'mini_portile2', '~> 2.0'
|
24
|
-
s.add_development_dependency 'rake', '~> 13.0'
|
25
|
-
s.add_development_dependency 'rake-compiler', '~> 1.
|
26
|
-
s.add_development_dependency 'rake-compiler-dock', '~> 1.0'
|
27
|
-
s.add_development_dependency 'minitest', '~> 5.
|
28
|
-
s.add_development_dependency '
|
23
|
+
s.add_development_dependency 'mini_portile2', '~> 2.5.0'
|
24
|
+
s.add_development_dependency 'rake', '~> 13.0.0'
|
25
|
+
s.add_development_dependency 'rake-compiler', '~> 1.2'
|
26
|
+
s.add_development_dependency 'rake-compiler-dock', '~> 1.3.0'
|
27
|
+
s.add_development_dependency 'minitest', '~> 5.14.0'
|
28
|
+
s.add_development_dependency 'minitest-ci', '~> 3.4.0'
|
29
|
+
s.add_development_dependency 'connection_pool', '~> 2.2.0'
|
29
30
|
s.add_development_dependency 'toxiproxy', '~> 2.0.0'
|
30
31
|
end
|