Download presentation
Presentation is loading. Please wait.
Published byAlexina Franklin Modified over 8 years ago
1
Continuous Integration for Databases Steve Jones SQLServerCentral Red Gate Software
2
Agenda Goals Who am I? What is Continuous Integration? Fitting in the Delivery Pipeline What is “build” for databases? Testing in a CI process Adding data for realism
3
Goals Why continuous integration? Testing is important It’s easy – setup and running in an hour Do feel free to ask questions!
4
Get in touch www.voiceofthedba.com sjones@sqlservercentral.com @way0utwest Steve Jones /in/way0utwest
5
“Continuous Integration is a practice designed to ensure that your software is always working, and that you get comprehensive feedback in a few minutes as to whether any given change to your system has broken it.” What is continuous integration? Jez Humble, ThoughtWorks, author of “Continuous Delivery”
6
“Database Continuous Integration is a practice designed to ensure that your database software is always working, and that you get comprehensive feedback in a few minutes as to whether any given change to your system has broken it.” What is continuous integration? database ^ Jez Humble, ThoughtWorks, author of “Continuous Delivery”
7
Development Continuous integration Build Test Publish Sync ALTER TABLE foo… Deployment script Release management Artifact repository Production Trigger Review, Backup & deploy Source control QA / Test / Pre-production Database release pipeline Continuous Integration DevelopmentProduction Testing Operations Database development and change management Continuous delivery for databases
8
Database release pipeline Continuous Integration DevelopmentProduction Testing Operations Database development and change management Developme nt Continuo us integratio n Build Test Publish Sync ALTER TABLE foo… Deploymen t script Release management Artifact repository Product ion Trigger Revie w, Backu p & deplo y Sour ce contr ol QA / Test / Pre- production Continuous delivery for databases Developme nt Continuo us integratio n Build Test Publish Sync ALTER TABLE foo… Deploymen t script Release management Artifact repository Product ion Trigger Revie w, Backu p & deplo y Sour ce contr ol QA / Test / Pre- production Continuous delivery for databases SalesApp Dev Trunk SalesApp Dev Bug Fixes
9
Database release pipeline Continuous Integration DevelopmentProduction Testing Operations Database development and change management Development Continuous integration Build Test Publish Sync ALTER TABLE foo… Deployment script Release management Artifact repository Production Trigger Review, Backup & deploy Source control QA / Test / Pre-production Continuous delivery for databases SalesApp Dev Trunk SalesApp Dev Bug Fixes Finance Dev Trunk Development Continuous integration Build Test Publish Sync ALTER TABLE foo… Deployment script Release management Artifact repository Production Trigger Review, Backup & deploy Source control QA / Test / Pre-production Continuous delivery for databases Development Continuous integration Build Test Publish Sync ALTER TABLE foo… Deployment script Release management Artifact repository Production Trigger Review, Backup & deploy Source control QA / Test / Pre-production Continuous delivery for databases
10
Continuous Integration
11
What is build? For application code = compile For database code = database creation script –But only for a new installation! –Upgrade scripts required for existing installations –Need to preserve the state of the data
12
Tools we need CI server –Perform the build for us –Execute steps we program Choices –TeamCity by JetBrainsTeamCity –Jenkins – open sourceJenkins –Bamboo – AtlassianBamboo –TFS Build - MicrosoftTFS Build –Cruise Control – open sourceCruise Control
13
Tools we need Database Integration –Check out schema from VCS –Execute against a SQL Server instance. –Run tests –Deploy to Integration Choices –Red Gate DLM Automation SuiteRed Gate DLM Automation Suite –PoSh –.NET scripts/program –?
14
Tools we need Version Control System (VCS) –Store our database DDL and DML Choices –SubversionSubversion –Team Foundation Server –Git –Mercurial –Visual SourceSafe –etc
15
Tools we need Testing framework –We need a way to unit test our code easily. –A framework allows us to write tests that we can maintain Choices –tSQLt and SQL TesttSQLtSQL Test –Microsoft Unit TestsMicrosoft Unit Tests –TSQLUnitTSQLUnit –TSTTST –DBUnit
16
Tools we need Test data –Add known or random data to our CI database. Choices –Red Gate SQL Data GeneratorRed Gate SQL Data Generator –Restore known backup –Custom scripts for data load (DML and/or BCP)
17
Our story… We want to set up a CI process fo r our database Our database is in a VCS o We need to automatically build a new database on every check-in
18
Continuous Integration Setup and data change Setup CI Server project Setup Build Step Setup Sync Step Demo
19
The CI Database Setup Developer CI Server Repository Integration Database
20
The CI Database Setup Developer CI Server Repository Integration Database
21
CI Process The CI Database Setup Developer CI Server Repository Integration Database Nuget Pkg SimpleTalkDB
22
CI Process The CI Database Setup Developer CI Server Repository Integration Database Random Test Database Nuget Pkg SimpleTalkDB
23
CI Process The CI Database Setup Developer CI Server Repository Integration Database Random Test Database Build Database from Scratch and validate Nuget Pkg SimpleTalkDB
24
CI Process The CI Database Setup Developer CI Server Repository Integration Database Nuget Pkg SimpleTalkDB Apply Upgrade
25
Keeping a database up to date With? Schema Static data Why? A corresponding database for the application Maintaining a test database with the latest changes
26
TESTING Why it’s important
27
Where does testing happen? Testing isn’t just done in QA Be aware of the cost of fixing a bug
28
Cost of Bugs
29
Does the cost of bugs rise?
31
Testing in Development Low(er) costs –No inter-team interactions –Changes are discrete However –Increased frequency of changes (higher cost)
32
What is test? For.NET code, Nunit –Runs on a developer’s machine and build server What about the database? –tSQLt is an open source framework for testing SQL Server databases –tSQLt.org –Support via GoogleGroups –SQL Test provides SSMS integration
33
Our story… We want to set up a CI process fo r our database Our database is in a VCS We need to automatically build a new database on every check-in o Let’s add a unit test for our code to the CI process.
34
Testing the Build Add a test step to the build Add a test Add a dev change to verify sync Demo
35
Why generate test data? Dev environments are often not realistic Getting production data not always possible Random data can result in surprises Volume testing can find performance issues
36
Our story… We want to set up a CI process fo r our database Our database is in a VCS We need to automatically build a new database on every check-in Let’s add a unit test for our code to the CI process. o Let’s generate test data to use in our CI process
37
Demo Testing with larger data sizes Change the Test step to generate data Build a data generation project Trigger the build
38
Two bugs found by Test Data 1.NULL Dates –App code assumed [Date] wouldn’t be NULL –Test data didn’t –Fix was to change [Date] to be NOT NULL 2. Performance of v_Articles –Test passed on dev box –Failed in more “realistic” CI environment
39
Deployments Scripts Creation scripts –For new installations Upgrade Scripts –For existing installations Developed by comparing our up-to-date database to production/test
40
Development Continuous integration Build Test Publish Sync ALTER TABLE foo… Deployment script Release management Artifact repository Production Trigger Review, Backup & deploy Source control QA / Test / Pre-production Database release pipeline Continuous Integration DevelopmentProduction Testing Operations Database development and change management Continuous delivery for databases
41
The End Questions? More information: www.red-gate.com/CI Please fill out your feedback forms http://voiceofthedba.wordpress.com/ sjones@sqlservercentral.com @way0utwest /in/way0utwest
42
References http://assets.red-gate.com/products/sql- development/assets/continuous-integration-using-red-gate-tools.pdf http://assets.red-gate.com/products/sql- development/assets/continuous-integration-using-red-gate-tools.pdf http://www.jetbrains.com/teamcity/ http://www.jetbrains.com/teamcity/ http://developers.slashdot.org/story/03/10/21/0141215/software- defects---do-late-bugs-really-cost-more http://developers.slashdot.org/story/03/10/21/0141215/software- defects---do-late-bugs-really-cost-more http://tech.lds.org/index.php?option=com_content&view=article&id=23 8:the-cost-of-bugs&catid=1:miscellanous http://tech.lds.org/index.php?option=com_content&view=article&id=23 8:the-cost-of-bugs&catid=1:miscellanous http://www.manageware.co.il/solution/portfolio/auto-deploy/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.