Skip to content

Commit

Permalink
Final Appveyor work.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Aug 3, 2015
1 parent 9cd0509 commit 12602d6
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 48 deletions.
17 changes: 16 additions & 1 deletion README.md
Expand Up @@ -333,7 +333,21 @@ The compiled gems will exist in `./pkg/`.

## Development & Testing

We use bundler for development. Simply run `bundle install` then `rake` to build the gem and run the unit tests. The tests assume you have created a database named `tinytdstest` accessible by a database owner named `tinytds`. Before running the test rake task, you may need to define a pair of environment variables that help the client connect to your specific FreeTDS database server name and which schema (2000, 2005, 2008, 2014, Azure or Sybase ASE) to use. For example:
First make sure your local database has a `[tinytdstest]` database with a owner login named `[tinytds]` having no password. The following SQL run via the `sa` account should set that up for you.

```sql
CREATE DATABASE [tinytdstest];
GO
CREATE LOGIN [tinytds] WITH PASSWORD = '', CHECK_POLICY = OFF, DEFAULT_DATABASE = [tinytdstest];
GO
USE [tinytdstest];
CREATE USER [tinytds] FOR LOGIN [tinytds];
GO
EXEC sp_addrolemember N'db_owner', N'tinytds';
GO
```

We use bundler for development. Simply run `bundle install` then `rake` to build the gem and run the unit tests. Before running the test rake task, you may need to define a pair of environment variables that help the client connect to your specific FreeTDS database server name and which schema (2000, 2005, 2008, 2014, Azure or Sybase ASE) to use. For example:

```
$ rake TINYTDS_UNIT_DATASERVER=mydbserver
Expand Down Expand Up @@ -373,6 +387,7 @@ My name is Ken Collins and I currently maintain the SQL Server adapter for Activ

## Special Thanks

* Lars Kanis for all his help getting the Windows builds working again with rake-compiler-dock.
* Erik Bryn for joining the project and helping me thru a few tight spots. - http://github.com/ebryn
* To the authors and contributors of the Mysql2 gem for inspiration. - http://github.com/brianmario/mysql2
* Yehuda Katz for articulating ruby's need for proper encoding support. Especially in database drivers - http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/
Expand Down
39 changes: 24 additions & 15 deletions appveyor.yml
@@ -1,28 +1,37 @@
version: 0.6.3.rc2.{build}
shallow_clone: true
init:
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
- SET PATH=C:\MinGW\msys\1.0\bin;%PATH%
- SET RAKEOPT=-rdevkit
clone_depth: 5
skip_tags: true
matrix:
fast_finish: true
services:
- mssql2014
install:
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
- SET PATH=C:\MinGW\msys\1.0\bin;%PATH%
- SET RAKEOPT=-rdevkit
- echo %APPVEYOR_BUILD_FOLDER%
- ruby --version
- gem --version
- bundle install
- bundle exec rake build
build: off
test_script:
- powershell -NoExit "& ""C:\projects\tiny-tds\test\appveyor\sqlserver_2014.ps1"""
- bundle exec rake TINYTDS_UNIT_DATASERVER="localhost\SQL2014" TINYTDS_UNIT_DATABASE=master TINYTDS_UNIT_USER=sa TINYTDS_UNIT_PASS=Password12!
- timeout /t 4 /nobreak > NUL
- powershell -File "%APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.ps1"
- timeout /t 4 /nobreak > NUL
- ps: Start-Service 'MSSQL$SQL2014'
- timeout /t 4 /nobreak > NUL
- sqlcmd -S ".\SQL2014" -U sa -P Password12! -i %APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.sql
- bundle exec rake TINYTDS_UNIT_HOST_TEST=localhost TINYTDS_UNIT_DATASERVER="localhost\SQL2014" TINYTDS_SCHEMA=sqlserver_2014
- ps: Stop-Service 'MSSQL$SQL2014'
- ps: Start-Service 'MSSQL$SQL2012SP1'
- timeout /t 4 /nobreak > NUL
- sqlcmd -S ".\SQL2012SP1" -U sa -P Password12! -i %APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.sql
- bundle exec rake TINYTDS_UNIT_HOST_TEST=localhost TINYTDS_UNIT_DATASERVER="localhost\SQL2012SP1" TINYTDS_SCHEMA=sqlserver_2014
- ps: Stop-Service 'MSSQL$SQL2012SP1'
- ps: Start-Service 'MSSQL$SQL2008R2SP2'
- timeout /t 4 /nobreak > NUL
- sqlcmd -S ".\SQL2008R2SP2" -U sa -P Password12! -i %APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.sql
- bundle exec rake TINYTDS_UNIT_HOST_TEST=localhost TINYTDS_UNIT_DATASERVER="localhost\SQL2008R2SP2" TINYTDS_SCHEMA=sqlserver_2014
environment:
matrix:
# - ruby_version: "193"
#- ruby_version: "200"
#- ruby_version: "200-x64"
#- ruby_version: "21"
#- ruby_version: "21-x64"
#- ruby_version: "22"
- ruby_version: "193"
- ruby_version: "22-x64"
27 changes: 27 additions & 0 deletions test/appveyor/dbsetup.ps1
@@ -0,0 +1,27 @@

Write-Output "Setting up..."
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | Out-Null

Write-Output "Setting variables..."
$serverName = $env:COMPUTERNAME
$instances = @('SQL2008R2SP2', 'SQL2012SP1', 'SQL2014')
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer')

Write-Output "Configure Instances..."
foreach ($instance in $instances) {
Write-Output "Instance $instance ..."
Write-Output "Enable TCP/IP and port 1433..."
$uri = "ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instance']/ServerProtocol[@Name='Tcp']"
$tcp = $wmi.GetSmoObject($uri)
$tcp.IsEnabled = $true
foreach ($ipAddress in $Tcp.IPAddresses) {
$ipAddress.IPAddressProperties["TcpDynamicPorts"].Value = ""
$ipAddress.IPAddressProperties["TcpPort"].Value = "1433"
}
$tcp.Alter()
}

Set-Service SQLBrowser -StartupType Manual
Start-Service SQLBrowser
9 changes: 9 additions & 0 deletions test/appveyor/dbsetup.sql
@@ -0,0 +1,9 @@
CREATE DATABASE [tinytdstest];
GO
CREATE LOGIN [tinytds] WITH PASSWORD = '', CHECK_POLICY = OFF, DEFAULT_DATABASE = [tinytdstest];
GO
USE [tinytdstest];
CREATE USER [tinytds] FOR LOGIN [tinytds];
GO
EXEC sp_addrolemember N'db_owner', N'tinytds';
GO
27 changes: 0 additions & 27 deletions test/appveyor/sqlserver_2014.ps1

This file was deleted.

12 changes: 7 additions & 5 deletions test/client_test.rb
Expand Up @@ -52,7 +52,9 @@ class ClientTest < TinyTds::TestCase
end

it 'must be able to use :host/:port connection' do
client = new_connection :dataserver => nil, :host => ENV['TINYTDS_UNIT_HOST'], :port => ENV['TINYTDS_UNIT_PORT'] || 1433
host = ENV['TINYTDS_UNIT_HOST_TEST'] || ENV['TINYTDS_UNIT_HOST']
port = ENV['TINYTDS_UNIT_PORT_TEST'] || ENV['TINYTDS_UNIT_PORT'] || 1433
client = new_connection dataserver: nil, host: host, port: port
end unless sqlserver_azure?

end
Expand All @@ -68,12 +70,12 @@ class ClientTest < TinyTds::TestCase
end

it 'raises TinyTds exception with undefined :dataserver' do
options = connection_options :login_timeout => 1, :dataserver => '127.0.0.2'
options = connection_options :login_timeout => 1, :dataserver => 'DOESNOTEXIST'
action = lambda { new_connection(options) }
assert_raise_tinytds_error(action) do |e|
assert [20008,20009].include?(e.db_error_number)
assert_equal 9, e.severity
assert_match %r{unable to (open|connect)}i, e.message, 'ignore if non-english test run'
assert_equal 20012, e.db_error_number
assert_equal 2, e.severity
assert_match %r{server name not found in configuration files}i, e.message, 'ignore if non-english test run'
end
assert_new_connections_work
end
Expand Down

0 comments on commit 12602d6

Please sign in to comment.