Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright 2015 Varigence, Inc. Unit and Integration Testing in SSIS A New Approach Scott @varigence.

Similar presentations


Presentation on theme: "Copyright 2015 Varigence, Inc. Unit and Integration Testing in SSIS A New Approach Scott @varigence."— Presentation transcript:

1 Copyright 2015 Varigence, Inc. Unit and Integration Testing in SSIS A New Approach Scott Currie, Varigence @scottcurrie @bimlscript @varigence

2 Copyright 2015 Varigence, Inc. About us Scott Currie CEO Varigence Creator of Biml @scottcurrie http://Varigence.com Biml @bimlscript #biml Biml User Group – LinkedIn http://bimlscript.com

3 Copyright 2015 Varigence, Inc.

4 Agenda Learn how to build a system that makes authoring and management of tests so easy and reliable that non-technical users can provide test logic Overview of Testing Strategies Current Approaches to SSIS Testing The New Approach

5 Test a feature Tell me WHAT is broken Must be run in context of whole job Only pass after feature is complete “My car broke down…” Integration tests tell riddles Integration TestsUnit Tests Test a task, component, or sequence Tell me WHERE it’s broken Isolate individual bits of business logic Pass as soon as component is done “…because the alternator failed” Unit tests lie Type of Tests

6 For Fact Sales Table: The sales for 2013 for widgets should be $129,320 Output of test shows that sales are $98,275 Find the N reason(s) for this failure. Example of “Riddle” in Integration Test: Example of “Lie” in Unit Test: For Fact Sales Table: The unit tests of derived column, row count, lookups, etc. all pass. We have several unit tests, but not enough to show where the problem is.

7 Hand Rolled: Current Approaches to SSIS Testing

8 xUnit, NUnit, MSTest (http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks)http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks Simple Smalltalk Testing: With Patterns (Kent Beck) Each framework uses a slightly different approach to best integrate with the target language and runtime. Some or declarative, some are procedural, some are hybrids. All follow the same basic philosophy. Assemble, Act, Assert Aka Setup, Test, Teardown Current Approaches to Unit Testing

9 ssisUnit https://ssisunit.codeplex.com/ XML specification of Tests with ability to run EXEs, check variable values, etc. Lends itself to integration test scenarios. VSDT http://blogs.msdn.com/b/ssdt/archive/2012/12/07/getting-started-with-sql-server-database-unit-testing-in-ssdt.aspx Focused on database unit tests, but can also be used for SSIS integration testing SSIS Testing Frameworks

10 Copyright 2015 Varigence, Inc. Very Briefly Biml BIDS Helper Developer Code Shared Scripts Biml BimlScript Biml Engine Database & Schema (T-SQL) ETL (SSIS) All generated artifacts: 1.Open in BIDS and appear to be hand built 2.Deploy and run on unmodified SQL Server

11 Copyright 2015 Varigence, Inc. Biml:

12 Copyright 2015 Varigence, Inc. Biml:

13 Asserts Simple way to specify test logic Specify two expressions that should be equal Special asserts to quickly specify test logic that conform to patterns Specifying a Test

14 Copyright 2015 Varigence, Inc. Three Ways to Run These 1.Event Handler call to auto-generated package –No reverse-engineering into Biml –You never have to look at Biml 2.Inject Tests into Biml generated packages –You already use Biml to create your packages 3.Use a propriety tool to do Test injection –Biml power user

15 Copyright 2015 Varigence, Inc. INTEGRATION TESTS Patterns in Action

16 Row Count Validation Duplicate Business Keys Foreign Key Null Checks Business Logic Validation CheckExample Functional test of: Load process Select count(*) from Source Compared to Select count(*) from Destination Integration Test Patterns

17 Row Count Validation Duplicate Business Keys Foreign Key Null Checks Business Logic Validation CheckExample Functional test of: upsert mechanism SELECT D.DealHashId,COUNT(D.DealId) AS DuplicateCNT FROM _ODS.ODS.Deal AS D WHERE ActiveFlag = 1 GROUP BY D.DealHashId HAVING COUNT(D.DealId) > 1 Expected result: 0 (or eyeballing) Integration Test Patterns

18 Row Count Validation Duplicate Business Keys Foreign Key Null Checks Business Logic Validation CheckExample Functional test of: Lookup of FKs SELECT * FROM Table WHERE ForeignKey IS NULL Expected result: proper results. 0 records or not If there are results, check the lookup attribute in source. Integration Test Patterns

19 Row Count Validation Duplicate Business Keys Foreign Key Null Checks Business Logic Validation CheckExample Functional test of: Formulas, “recipes” CALC_Paid_Sev = Claim_Paid_Amt / Num_Clm_Paid SELECT 47964 AS Claim_Paid_Amt, 12.0 AS Num_Clm_Paid, 47964 / 12.0 AS CALC_Paid_Severity_CRE FROM CreditFileLoad Expected result: 3997 Integration Test Patterns Claim_Paid_AmtNum_Clm_PaidCALC_Paid_Severity_CRE 47964123997

20 Copyright 2015 Varigence, Inc. DEMO Integration Test Patterns

21 Copyright 2015 Varigence, Inc. UNIT TESTS Patterns in Action

22 Row Count Validation Duplicate Business Keys Foreign Key Null Checks Business Logic Validation CheckNOTE: You can do all of the same types of checks within your data flows for validating the business logic for individual components. Just change your “Target” attribute to match the refId of the dataflow component.refId Unit Test Patterns

23 Copyright 2015 Varigence, Inc. Wait! Do I have to test the WHOLE package? –It’s big –It contains private information –It takes many long steps to generate it –Developers can’t access or change it for debugging –It doesn’t include all possible corner cases –Accessing it might have side-effects –Doesn’t test contract (do you call expensive stored proc too many times?)

24 Copyright 2015 Varigence, Inc. Stub Objects –Sample data used only for tests –How to do stubs? o Tear target component out of dataflow o Create new dataflow using the stub as a source o Insert target component into the dataflow o Add assert checks after target component –Asserts customized for stubbed test data

25 Copyright 2015 Varigence, Inc. Stubbing Illustrated OLE DB Source OLE DB Dest Derived Columns Lookup Derived Columns Union All Derived Columns Stub Source Assert 1 Assert 2 Assert 3

26 Copyright 2015 Varigence, Inc. DEMO Stubbing

27 Copyright 2015 Varigence, Inc. http://tinyurl.com/ScottAndJulieNewApproach


Download ppt "Copyright 2015 Varigence, Inc. Unit and Integration Testing in SSIS A New Approach Scott @varigence."

Similar presentations


Ads by Google