sql server managing test data & stress testing january 2011

28
Managing Managing Test Data and Stress Test Data and Stress Managing Managing Test Data and Stress Test Data and Stress Testing Your SQL Applications Testing Your SQL Applications Speaker: Joel Champagne San Francisco SQL Server User Group January 12, 2011 Mark Ginnebaugh, User Group Leader www.bayareasql.org

Upload: mark-ginnebaugh

Post on 29-Nov-2014

2.165 views

Category:

Technology


3 download

DESCRIPTION

A quick look at some of the available functionality for SQL Server developers who have access to Visual Studio 2010 and SQL-Hero. With Visual Studio 2010 Premium (and Professional to a degree) delivering similar capabilities to what was available in VS 2008 Database Pro Edition, the ability to generate a mass amount of sample data for your database has only gotten more accessible with time. Realizing that other tools exist in this space and not all SQL developers use Visual Studio, we’ll also take a look at the third party data generation facility available in SQL-Hero, seeing how we can create thousands (or millions!) of records very quickly using a powerful rules engine, plus automate this process to support continuous integration strategies.

TRANSCRIPT

Page 1: SQL Server Managing Test Data & Stress Testing January 2011

Managing Managing Test Data and Stress Test Data and Stress Managing Managing Test Data and Stress Test Data and Stress Testing Your SQL Applications Testing Your SQL Applications

Speaker: Joel Champagne

San Francisco SQL Server User GroupJanuary 12, 2011

Mark Ginnebaugh, User Group Leaderwww.bayareasql.org

Page 2: SQL Server Managing Test Data & Stress Testing January 2011

Tonight’s SpeakerTonight’s Speakerg pg p

Joel Champagne Joel Champagne Developer of large enterprise applications for 20 years Focus on data, in particular using the Microsoft stack (SS*S) Focus on data, in particular using the Microsoft stack (SS S)

and .NET Involved in all stages of application life-cycle, from

envisioning through implementation Areas of Interest:

Tool development work Developer productivity

T i ht’ T i M i T t D t d St T ti Tonight’s Topic: Managing Test Data and Stress Testing Your SQL Applications

Page 3: SQL Server Managing Test Data & Stress Testing January 2011

Upcoming TrainingUpcoming Training 

• Upcoming full‐day training (minimal cost, target is p g y g ( , glate Feb or March 2011):  www.codexframework.com/training

SQL Source Control– SQL Source Control– Stress/Volume Testing– SQL Unit Testing– SQL‐Hero – more details (www.codexframework.com)

l l l d f k• Email Joel:  [email protected]• Twitter:  @sqlheroguy

Page 4: SQL Server Managing Test Data & Stress Testing January 2011

What I want to cover…What I want to cover…

• The why & howThe why & how

• Large data volumes – benefits, practical looks

S ifi l i d il• Specific examples, in detail

• Obfuscation of existing data

• Load testing

• Both MS and non‐MS optionsBoth MS and non MS options

• Let’s keep it interactive

Page 5: SQL Server Managing Test Data & Stress Testing January 2011

In the beginning…In the beginning…

• … of the development process… of the development process– We can know characteristics of entities– We can know ways to optimize (e.g. indexes)y p ( g )– We can have good intentions

• Ultimately, the little details matter:Ultimately, the little details matter:– Style counts! – not always shortest or most elegant performs best

– SQL can seem like an art instead of a science sometimes

Page 6: SQL Server Managing Test Data & Stress Testing January 2011

Problem is…Problem is…

• How can we know what we’ve got is going to:o ca e o at e e got s go g to:– Perform well, not just as we develop, but years from now, in production

– Perform well if reality changes– Actually  behave as expected with lots of data

A d ’d lik t• And, we’d like to:– Work with semi‐realistic data, even before users have had a chance to do a lot of interaction with the apphad a chance to do a lot of interaction with the app

– In some cases may want to work with a “well known” data set, to support repeatable unit & system testing

Page 7: SQL Server Managing Test Data & Stress Testing January 2011

SolutionsSolutions

• VS 2010VS 2010– Database project ‐> Data Generation Plan– Premium/Ultimate/– Custom generator extensibility

• SQL‐HeroSQL Hero– Generate data option

• OthersOthers– Custom developed (scripting, bcp, PowerShell, etc.)

Page 8: SQL Server Managing Test Data & Stress Testing January 2011

Things to consider…Things to consider…

• “Realism”Realism– Cardinality– Use of NULL– Foreign key lookups– Implied rules (sequence number example)p ( q p )– … essentially rules at both column and table level (constraints)

– Names, addresses, etc. – pros, cons

• Deterministic vs. True Random

Page 9: SQL Server Managing Test Data & Stress Testing January 2011

Understanding reality…Understanding reality…Cardinality:

Page 10: SQL Server Managing Test Data & Stress Testing January 2011

Scenario #1Scenario #1

• New development effort empty databaseNew development effort, empty database

• We have a search screen we’ve written –seems like it’s fast but not a lot of dataseems like it s fast but not a lot of data

• … what about 3 years from now?– 12,000,000+ Customers

– 26,000,000+ Orders

– 16,500,000 Addresses

Page 11: SQL Server Managing Test Data & Stress Testing January 2011

Options #1Options #1

• VS 2010VS 2010

• SQL‐Hero

• Data Model

• Demos

Page 12: SQL Server Managing Test Data & Stress Testing January 2011
Page 13: SQL Server Managing Test Data & Stress Testing January 2011

Scenario #2Scenario #2

• Let’s take an end‐to‐end look at a “real example” et s ta e a e d to e d oo at a ea e a p efrom a customer…– Team structure– “The strategy”

• A fourth database, user participation

Design doc from BA– Design doc from BA– The process of creating data and testing– Tuning effortsTuning efforts– Re‐testing– Conclusions…

Page 14: SQL Server Managing Test Data & Stress Testing January 2011
Page 15: SQL Server Managing Test Data & Stress Testing January 2011
Page 16: SQL Server Managing Test Data & Stress Testing January 2011
Page 17: SQL Server Managing Test Data & Stress Testing January 2011

Scenario #3Scenario #3

• Large database, on‐going development work, g , g g p ,post‐implementation

• As we try to modify or fix bugs, some issues rely on production quality dataon production‐quality data

• Option:  Copy prod to dev/QA• Problems:• Problems:

– Security– Coordinating with on‐going dev work

• Another scenario:  just looking to add more data to an existing DB

Page 18: SQL Server Managing Test Data & Stress Testing January 2011

Options #3Options #3

• VS 2010VS 2010– Data Transformation

• SQL Hero• SQL‐Hero– “Scramble” existing data option

• Demos

Page 19: SQL Server Managing Test Data & Stress Testing January 2011

Issue here:  Assumes inherently that should reseed…

Conclusions…‐ Data generation plans are very extensible (due to custom generators and such)but do have limitations:  prepare to invest some time in getting them “just right”

Page 20: SQL Server Managing Test Data & Stress Testing January 2011

Scenario #4Scenario #4

• Actual “stress testing” being high concurrentActual  stress testing , being high concurrent load

• Need to understand the results of high load• Need to understand the results of high load– Slowness

Of i bl ki– Often times, blocking

– Sometimes deadlocks we didn’t anticipate

– Have seen lead to on‐going monitoring, tuning efforts

Page 21: SQL Server Managing Test Data & Stress Testing January 2011

Options #4• SQLIO

– SQLIOStress creates separate data and log files to simulate the I/O patterns that SQL Server will generate to its data file (.mdf) and its log file (.ldf). SQLIOStress does not use the SQL Server engine to perform the(.ldf). SQLIOStress does not use the SQL Server engine to perform the stress activity so it can be used to exercise a computer before you install SQL Server." (From SQLIOStress Readme.doc)

• SQL ProfilerC ll kl d d “ l ”– Can collect a workload and “replay”

• VS 2010– Extensive Load Testing support – Test rigs, multiple agents possible

Invocation of test cases in NET pros and cons– Invocation of test cases in .NET – pros and cons• SQL‐Hero

– Executing script with concurrency option – generate high load using “real” trace – simple, visualization for results ‐ successfultrace  simple, visualization for results  successful

– Data visualization of collected trace information (often the key in analysis)– Data visualization of trace information, over longer timeframes– Production monitoringg– Screen shots:  daily life examples– Future:  Template to build web test code to invoke from VS2010 test rig

Page 22: SQL Server Managing Test Data & Stress Testing January 2011
Page 23: SQL Server Managing Test Data & Stress Testing January 2011
Page 24: SQL Server Managing Test Data & Stress Testing January 2011
Page 25: SQL Server Managing Test Data & Stress Testing January 2011
Page 26: SQL Server Managing Test Data & Stress Testing January 2011
Page 27: SQL Server Managing Test Data & Stress Testing January 2011

Putting it together…Putting it together…

• Build processu d p ocess– Build DB from SC ‐> Populate Fully ‐> Use

• Advantage:  you know will match source of truth• Disadvantage:  longer‐term testing, relying on existing data

– Scripting / automationMicrosoft guidance doc:– Microsoft guidance doc: http://vsdatabaseguide.codeplex.com

– Hybrid options common

• Another important element:  Unit testing– Knowing if something becomes broken, early

Page 28: SQL Server Managing Test Data & Stress Testing January 2011

To learn more or inquire about speaking opportunities, please q p g pp , pcontact:

Mark Ginnebaugh, User Group Leader [email protected]