Skip to content

SqlSetup\Set-TargetResource Unit Tests very slow to execute #2097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dan-hughes opened this issue Apr 22, 2025 · 1 comment
Open

SqlSetup\Set-TargetResource Unit Tests very slow to execute #2097

dan-hughes opened this issue Apr 22, 2025 · 1 comment
Labels
help wanted The issue is up for grabs for anyone in the community. tests The issue or pull request is about tests only.

Comments

@dan-hughes
Copy link
Contributor

This is not something that happens to me locally but on Azure DevOps the tests are taking 20+ seconds each to run.

@dan-hughes dan-hughes changed the title SqlSetup\Set-TargetResource Tests very slow to execute SqlSetup\Set-TargetResource Unit Tests very slow to execute Apr 22, 2025
@johlju
Copy link
Member

johlju commented Apr 22, 2025

I have refactored the tests for that resource when converting to Pester 5. They were extremely complex then, but the tests are still very complex now. As I recall they run slow for me as well on my PC.

I think only way to fix it is to do a refactor again, but not sure if it is worth it? Most likely, but only guessing, it is a mocking thing connected to a ForEach-testcases. 🤔

Before when I have seen time differences it is because mocking is not done at the first level, but second or third level (command call "nesting level"). Not sure if it was in Pester 5, maybe Pester 4. 🤔 But could also be a bug in the tests somewhere that not showing up in Azure DevOps for some reason. There were actually a mocking bug in the Pester 4 tests that prevented me to run the tests locally, but they passed in Azure DevOps. I never understood why. But I fixed it in Pester 5 tests.

Anyway. I have for the past 2-3 years worked on refactoring this resource into a new SqlInstall that uses public commands (and the goal is to make it faster) to do things. To move out most logic to separate units to run an tests so it wouldn't be so complex. But that worked has stalled as it takes a lot of time as I need to test everything live in VM's.
PR for SqlInstall: #1912

@johlju johlju added tests The issue or pull request is about tests only. help wanted The issue is up for grabs for anyone in the community. labels Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted The issue is up for grabs for anyone in the community. tests The issue or pull request is about tests only.
Projects
None yet
Development

No branches or pull requests

2 participants