Invoke-DlmDatabaseTests : tSQLt needs to be installed
tomslickers
Posts: 40 Bronze 2
I am trying to use DLM automation to automate database CI per Alex Yate's following post:
https://www.red-gate.com/hub/product-learning/dlm-automation/database-continuous-integration-with-redgate-dlm-automation-powershell-and-jenkins
Everything works except for InvokeDlmDatabaseTests which fails with the following error:
Cleaning database 'TemporaryDb' on server 'localhost'.
Running tests contained in database package
Invoke-DlmDatabaseTests : tSQLt needs to be installed to run the tests on JenkinsTest.0.79 Database Package.
How do I install SQL Test in the TemporaryDB?
https://www.red-gate.com/hub/product-learning/dlm-automation/database-continuous-integration-with-redgate-dlm-automation-powershell-and-jenkins
Everything works except for InvokeDlmDatabaseTests which fails with the following error:
Cleaning database 'TemporaryDb' on server 'localhost'.
Running tests contained in database package
Invoke-DlmDatabaseTests : tSQLt needs to be installed to run the tests on JenkinsTest.0.79 Database Package.
How do I install SQL Test in the TemporaryDB?
Tagged:
Best Answer
-
tomslickers Posts: 40 Bronze 2Thanks Alex! I should have figured that out. Installing the tSQLt objects in the Dev database and committing them to source control did the trick.
Answers
First, a quick question:
Have you added tSQLt on your dev DB and committed it to source control?
If not, the reason you get the error is that when DLMA builds the DB it doesn't have the tSQLt objects (because your source code doesn't have the tSQLt objects) - hence the error.
If you do have the tSQLt objects in source control, are you using a persistent temporary database (i.e. a specific named database using the -TemporaryDatabase parameter) or did you exclude that parameter, allowing DLMA to create a temporary scratch DB for you with a GUID for a name?
If you are using the -TemporaryDatabase parameter, have you set TRUSTWORTHY to ON on that database? TRUSTWORTHY is required to be on in order for tSQLt to work. I believe the cmdlet will deploy tSQLt for you (assuming it's in source control), but tSQLt will only work if the DB has TRUSTWORTHY enabled. If it is not enabled you can get some unintuitive error messages.
To enable trustworthy:
ALTER DATABASE dbname SET TRUSTWORTHY ON;
Note: Do not do this on production. TRUSTWORTHY is a bad idea on production:
https://stackoverflow.com/questions/27006432/security-risks-of-setting-trustworthy-on-in-sql-server-2012
Let me know if that helps.
DevOps Mentor and Coach
Director of DLM Consultants
Creator of Speaking Mentors
Microsoft Data Platform MVP
Friend of Redgate
Twitter / LinkedIn
If using Redgate SQL Test:
https://documentation.red-gate.com/sqt2/adding-a-database-to-sql-test
If not using Redgate SQL Test:
http://tsqlt.org/user-guide/quick-start/
DevOps Mentor and Coach
Director of DLM Consultants
Creator of Speaking Mentors
Microsoft Data Platform MVP
Friend of Redgate
Twitter / LinkedIn