0

I am trying to write integration tests for SSIS packages. The SSIS package has been deployed to the SSIS catalog (SSISDB). I am using a server with the Winders Server 2012 OS, and am using SQL Server 2012

My code is below

EXEC tSQLt.NewTestClass 'testClass'

CREATE PROCEDURE testClass.[test ssis package integration]
AS

BEGIN
IF OBJECT_ID('actual') IS NOT NULL DROP TABLE actual;
IF OBJECT_ID('expected') IS NOT NULL DROP TABLE expected;


/* Assemble
   --------------------------------------------------------------------- */

/* Clear source tables */
TRUNCATE TABLE [Database1].[dbo].[table1];
TRUNCATE TABLE [Database1].[dbo].[table2];

/* Clear destination tables */
TRUNCATE TABLE [Database2].[dbo].[table1];

/* Insert set up data */
---

/* Create expected table */
CREATE TABLE expected (
    ID      INT,
    Code    NVARCHAR(50)
);

/* Insert expected data */
---

/* Act 
   --------------------------------------------------------------------- */

/* Execute SSIS package */
DECLARE @execution_id BIGINT;
EXEC [SSISDB].[catalog].[create_execution] @package_name=N'Portfolio.dtsx', @execution_id=@execution_id OUTPUT, @folder_name=N'DDoubleU', @project_name=N'PortfolioMaster', @use32bitruntime=False, @reference_id=Null;

DECLARE @var0 SMALLINT = 1;
EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id,  @object_type=50, @parameter_name=N'LOGGING_LEVEL', @parameter_value=@var0;
EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id,  @object_type=50, @parameter_name=N'SYNCHRONIZED', @parameter_value=1
EXEC [SSISDB].[catalog].[start_execution] @execution_id;


/* Select record with MAX data load ID because we want the data set just created*/
SELECT [ID], [Code]
    INTO actual
    FROM [Database2].[dbo].[table1];


/* Assert  
   --------------------------------------------------------------------- */
EXEC tSQLt.AssertEqualsTable 'expected', 'actual';


/* Clean up
   --------------------------------------------------------------------- */
DROP TABLE actual;
DROP TABLE expected;

END;

The issue I have is that when I execute the below command in SSMS

EXEC tSQLt.Run 'testClass';

The SSIS package does not trigger.

Things I have tried so far:

Reading this post on stack - from what I can see I've created my test as described here.

Running the code that is supposed to execute the SSIS package in isolation in SSMS. This works as expected. By this I mean the package executes and the data in the destination table is what I expect.

Adding a WAITFOR DELAY command after the [start_execution] command to make sure that the SSIS package has time to complete, but this doesn't seem to be the issue.

Uninstalling tSQLt and re-installing it.

Community
  • 1
  • 1
GreenyMcDuff
  • 3,292
  • 7
  • 34
  • 66
  • Have you run the package from SSMS? does it work from there – Ramin May 06 '16 at 08:36
  • Yes - that's where I tested the SSIS package execution code in isolation and it worked fine. When I run the tSQLt.Run command in SSMS it doesn't execute the package. – GreenyMcDuff May 06 '16 at 08:45
  • it may worth to double check your siss script. e.g. config ```SYNCHRONIZED``` refer to: http://stackoverflow.com/questions/17447994/unit-testing-of-ssis-package-with-tsqlt – Guoliang May 06 '16 at 09:11
  • Thanks - but I have already checked the script. The link you provided was the same one I gave in my question. – GreenyMcDuff May 06 '16 at 12:17
  • I've also tried analysing the Package execution status. The status of the package is always 5 (Pending) when I execute the code using the `tSQLt.Run` command. I'm not sure what could be causing this, but it's a bit more information. – GreenyMcDuff May 06 '16 at 18:25
  • Thought I'd add my conclusion here to save anyone else spending a lot of time on this. tSQLt operates in it's own transaction. Upon completion (error, failure or success) the transaction is rolled back. Executing SSIS using the above method will always leave the package in a pending status (status = 5) unless you commit the transaction first (but that negates the "clean" nature of the test). There is one more method I'm yet to investigate which is adding the SSIS process to the current transaction. – GreenyMcDuff May 21 '16 at 20:31

0 Answers0