add scripts to create required databases and users for integration tests
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
rem scripts to setup integration test database on CI server
|
||||
rem NOTE: sqlcmd params are hard-coded to credentials and instance name for SQL Server 2012 as per http://www.appveyor.com/docs/services-databases
|
||||
|
||||
rem first, create the databases and the SpringQA user
|
||||
sqlcmd -S ".\SQL2012SP1" -U sa -P Password12! -i "%APPVEYOR_BUILD_FOLDER%\build-support\create-integration-test-databases-and-users.sql
|
||||
|
||||
rem add the 'Spring' schema and data
|
||||
sqlcmd -S ".\SQL2012SP1" -U sa -P Password12! -i "%APPVEYOR_BUILD_FOLDER%\test\Spring\Spring.Data.Integration.Tests\Data\Spring.Data.Integration.Tests_Spring_database.sql"
|
||||
|
||||
rem add the 'Credits' schema
|
||||
sqlcmd -S ".\SQL2012SP1" -U sa -P Password12! -i "%APPVEYOR_BUILD_FOLDER%\test\Spring\Spring.Data.Integration.Tests\Data\Spring.Data.Integration.Tests_Credits_database.sql"
|
||||
|
||||
rem add the 'Debits' schema
|
||||
sqlcmd -S ".\SQL2012SP1" -U sa -P Password12! -i "%APPVEYOR_BUILD_FOLDER%\test\Spring\Spring.Data.Integration.Tests\Data\Spring.Data.Integration.Tests_Debits_database.sql"
|
||||
|
||||
rem add the 'CreditsAndDebits' schema
|
||||
sqlcmd -S ".\SQL2012SP1" -U sa -P Password12! -i "%APPVEYOR_BUILD_FOLDER%\test\Spring\Spring.Data.Integration.Tests\Data\Spring.Data.Integration.Tests_CreditsAndDebits_database.sql"
|
||||
|
||||
|
||||
40
build-support/appveyor-set-sql-alias-for-springqa.ps1
Normal file
40
build-support/appveyor-set-sql-alias-for-springqa.ps1
Normal file
@@ -0,0 +1,40 @@
|
||||
#borrowed from https://habaneroconsulting.com/Insights/Create-a-SQL-Alias-with-a-PowerShell-Script.aspx
|
||||
|
||||
#This is the name of your SQL Alias
|
||||
$AliasName = "SpringQA"
|
||||
|
||||
#This is the name of your SQL server (the actual name!)
|
||||
$ServerName = $env:COMPUTERNAME
|
||||
|
||||
$InstanceName = "SQL2012SP1"
|
||||
|
||||
#These are the two Registry locations for the SQL Alias locations
|
||||
$x86 = "HKLM:\Software\Microsoft\MSSQLServer\Client\ConnectTo"
|
||||
$x64 = "HKLM:\Software\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo"
|
||||
|
||||
#We're going to see if the ConnectTo key already exists, and create it if it doesn't.
|
||||
if ((test-path -path $x86) -ne $True)
|
||||
{
|
||||
write-host "$x86 doesn't exist"
|
||||
New-Item $x86
|
||||
}
|
||||
if ((test-path -path $x64) -ne $True)
|
||||
{
|
||||
write-host "$x64 doesn't exist"
|
||||
New-Item $x64
|
||||
}
|
||||
|
||||
#Adding the extra "fluff" to tell the machine what type of alias it is
|
||||
$TCPAlias = "DBMSSOCN," + $ServerName + "\" + $InstanceName
|
||||
#$NamedPipesAlias = "DBNMPNTW,\\" + $ServerName + "\pipe\" + "MSSQL$" + $InstanceName + "\sql\query"
|
||||
|
||||
#Creating our TCP/IP Aliases
|
||||
New-ItemProperty -Path $x86 -Name $AliasName -PropertyType String -Value $TCPAlias -Force
|
||||
New-ItemProperty -Path $x64 -Name $AliasName -PropertyType String -Value $TCPAlias -Force
|
||||
|
||||
#WARNING: left here in case we ever want to switch to named-piped, but since we can't have two aliases
|
||||
# named the same for two diff. conn. protcols, this is commented out here in favor of the TCPIP alias above
|
||||
|
||||
#Creating our Named Pipes Aliases
|
||||
#New-ItemProperty -Path $x86 <20>Name $AliasName -PropertyType String -Value $NamedPipesAlias
|
||||
#New-ItemProperty -Path $x64 <20>Name $AliasName -PropertyType String -Value $NamedPipesAlias
|
||||
@@ -0,0 +1,89 @@
|
||||
--drop Spring DB if exists
|
||||
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'Spring')
|
||||
BEGIN
|
||||
ALTER DATABASE Spring
|
||||
SET SINGLE_USER
|
||||
WITH ROLLBACK IMMEDIATE
|
||||
|
||||
DROP DATABASE Spring
|
||||
END
|
||||
GO
|
||||
|
||||
--drop Credits DB if exists
|
||||
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'Credits')
|
||||
BEGIN
|
||||
ALTER DATABASE Credits
|
||||
SET SINGLE_USER
|
||||
WITH ROLLBACK IMMEDIATE
|
||||
|
||||
DROP DATABASE Credits
|
||||
END
|
||||
GO
|
||||
|
||||
--drop Debits DB if exists
|
||||
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'Debits')
|
||||
BEGIN
|
||||
ALTER DATABASE Debits
|
||||
SET SINGLE_USER
|
||||
WITH ROLLBACK IMMEDIATE
|
||||
|
||||
DROP DATABASE Debits
|
||||
END
|
||||
GO
|
||||
|
||||
--drop CreditsAndDebits DB if exists
|
||||
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'CreditsAndDebits')
|
||||
BEGIN
|
||||
ALTER DATABASE CreditsAndDebits
|
||||
SET SINGLE_USER
|
||||
WITH ROLLBACK IMMEDIATE
|
||||
|
||||
DROP DATABASE CreditsAndDebits
|
||||
END
|
||||
GO
|
||||
|
||||
-- if SpringQA user exists, drop it
|
||||
IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'springqa')
|
||||
DROP LOGIN [springqa]
|
||||
GO
|
||||
|
||||
-- create the databases
|
||||
CREATE DATABASE Spring
|
||||
GO
|
||||
|
||||
CREATE DATABASE Credits
|
||||
GO
|
||||
|
||||
CREATE DATABASE Debits
|
||||
GO
|
||||
|
||||
CREATE DATABASE CreditsAndDebits
|
||||
GO
|
||||
|
||||
CREATE DATABASE Spring
|
||||
GO
|
||||
|
||||
-- create the SpringQA login itself
|
||||
CREATE LOGIN [springqa] WITH PASSWORD=N'springqa', DEFAULT_DATABASE=[Spring], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION = OFF, CHECK_POLICY = OFF
|
||||
GO
|
||||
|
||||
-- set the SpringQA user as DB_OWNER for each of the databases...
|
||||
USE Spring
|
||||
CREATE USER [springqa] FOR LOGIN [springqa] WITH DEFAULT_SCHEMA=[dbo]
|
||||
EXEC sp_addrolemember 'db_owner', 'springqa'
|
||||
GO
|
||||
|
||||
USE Credits
|
||||
CREATE USER [springqa] FOR LOGIN [springqa] WITH DEFAULT_SCHEMA=[dbo]
|
||||
EXEC sp_addrolemember 'db_owner', 'springqa'
|
||||
GO
|
||||
|
||||
USE Debits
|
||||
CREATE USER [springqa] FOR LOGIN [springqa] WITH DEFAULT_SCHEMA=[dbo]
|
||||
EXEC sp_addrolemember 'db_owner', 'springqa'
|
||||
GO
|
||||
|
||||
USE CreditsAndDebits
|
||||
CREATE USER [springqa] FOR LOGIN [springqa] WITH DEFAULT_SCHEMA=[dbo]
|
||||
EXEC sp_addrolemember 'db_owner', 'springqa'
|
||||
GO
|
||||
Reference in New Issue
Block a user