dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Test-DbaAvailabilityGroup

Open wsmelton opened this issue 8 years ago • 4 comments

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:

  • IsPrimary (true/false based on if the server passed in is the primary or a secondary)
  • AG failover mode
  • Is the replica in sync with the primary (various queues that would be good to check to make sure everything is caught up, criticality of this would be based on the failover mode....just need to try and test this to really make sure).
  • AlwaysOn XE session is running
  • Are base disk/storage for each replica the same (sized the same across all replicas)

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

wsmelton avatar Sep 03 '17 09:09 wsmelton

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

andreasjordan avatar Aug 07 '21 11:08 andreasjordan

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

tboggiano avatar Mar 08 '22 17:03 tboggiano

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.

andreasjordan avatar Mar 08 '22 17:03 andreasjordan

OK. So, we could have a switches:

  • AddDatabase
  • HealthCheck
  • ReadyToFailover
  • ReadyToConfigure

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.

tboggiano avatar Mar 09 '22 00:03 tboggiano