Scuba Tanks are controlled by the US Department of Transportation (DOT).
Every five years the tanks must go through hydrostatic testing. A tank is filled to 5/3 its capacity with water. A typical 3000 psi tank is filled with 5000 psi of water (inside an armored tank). The steel or aluminum should flex under this pressure. This flex is measured.
Every year the tank must undergo a visual test. A certified tech will release the air, remove the valve and carefully inspect the inside and outside of the tank for corrosion and cracks.
The fact that tanks are required to be tested and inspected does not mean that they are. If buying a tank look for when it was last hydro tested. This will be stamped into the tank. Look at when it was last visually tested. This will be on a sticker. A well maintained tank will have a very long life. Aluminum tanks are engineered for 100,000 fills or 10,000 hydro tests. In the end, they last until they fail a test, and then they are condemned.
I own many tanks. When considering a purchase, take into account total cost of ownership. Testing is not inexpensive and the cost of filling your tank is close to the cost of renting a full tank.