dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.47k stars 802 forks source link

Test-DbaAvailabilityGroup #2190

Open wsmelton opened 7 years ago

wsmelton commented 7 years ago

Feature Request

Fresh issue to replace #543

A command that verifies an AG is in a good state.

Problem to solve

Mainly for the purpose of other commands that are to be built around AGs, such as changing a replica to be a primary, we need to know if an AG is in a state that it can be failed over at all. So the test function I would say should provide the following information:

For testing

Scripts are published that should allow us to test, if not via Appveyor on our own, to just verify the command works properly. The main thing to do is cause a high amount of activity in an AG database from the primary and have a secondary with low resources (small amount of RAM/CPU) to essentiality make it get behind. You can use Jonathan's script that I've also attached to this issue for safe keeping.

create enlarged adventureworks tables.txt

andreasjordan commented 3 years ago

If someone is interested working on this, see #7693.

tboggiano commented 2 years ago

@andreasjordan Can you let me know what tests you would like to see added to Test-DbaAvailabilityGroup?

andreasjordan commented 2 years ago

I don't have a set of tests in mind - that's why I have not worked on that. I have started Test-DbaAvailabilityGroup in a way that "Test-" is like "Test if the AG is in correct status to do X" with X beeing "Adding a new database" as a starting point.

The other direction could be a general health status - so using the DMVs and the health columns to report problems like the dashboard in SSMS. But I currently have no need for that - so I have not worked on that.

tboggiano commented 2 years ago

OK. So, we could have a switches:

is what I can see taking an initial look at ways I can see to use this command. Don't know if those things should be in separate functions to keep it clearer or if we want it all in one function. The later would require the FailoverCluster PowerShell module though. Some checks are in dbachecks for some of the things we could test in different ones of these. So, opinions on if we want these various switches in this function or which ones we want or do not want within in this command.