Skip to content
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

Replace Start-Sleep with Start-TestSleep for all test cases in CosmosDB #23780

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/GremlinOperationsTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,17 @@ function Test-GremlinInAccountRestoreOperationsCmdlets
$ListDatabases = Get-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListDatabases)

Start-Sleep -s 50
Start-TestSleep -s 50

# Delete the graph
$IsGraphRemoved = Remove-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $graphName -PassThru
Assert-AreEqual $IsGraphRemoved true

Start-Sleep -s 50
Start-TestSleep -s 50

Restore-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $graphName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 100
Start-TestSleep -s 100

# list graphs
$Listgraphs = Get-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand All @@ -481,7 +481,7 @@ function Test-GremlinInAccountRestoreOperationsCmdlets
$IsDatabaseRemoved = Remove-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -PassThru
Assert-AreEqual $IsDatabaseRemoved true

Start-Sleep -s 100
Start-TestSleep -s 100

Try {
Restore-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $graphName -RestoreTimestampInUtc $restoreTimestampInUtc
Expand All @@ -502,12 +502,12 @@ function Test-GremlinInAccountRestoreOperationsCmdlets
# Restore the deleted database
Restore-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 100
Start-TestSleep -s 100

# Restore the deleted graph
Restore-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $graphName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 50
Start-TestSleep -s 50

# List graphs
$Listgraphs = Get-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand Down Expand Up @@ -596,17 +596,17 @@ function Test-GremlinInAccountRestoreOperationsNoTimestampCmdlets
$ListDatabases = Get-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListDatabases)

Start-Sleep -s 50
Start-TestSleep -s 50

# Delete the graph
$IsGraphRemoved = Remove-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $graphName -PassThru
Assert-AreEqual $IsGraphRemoved true

Start-Sleep -s 50
Start-TestSleep -s 50

$Restoredgraph = Restore-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $graphName

Start-Sleep -s 100
Start-TestSleep -s 100

# list graphs
$Listgraphs = Get-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand All @@ -616,12 +616,12 @@ function Test-GremlinInAccountRestoreOperationsNoTimestampCmdlets
$IsDatabaseRemoved = Remove-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -PassThru
Assert-AreEqual $IsDatabaseRemoved true

Start-Sleep -s 100
Start-TestSleep -s 100

# Restore the deleted database
Restore-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName

Start-Sleep -s 100
Start-TestSleep -s 100

# Restore the deleted graph with no timestamp after database restore
Try {
Expand All @@ -631,7 +631,7 @@ function Test-GremlinInAccountRestoreOperationsNoTimestampCmdlets
Assert-AreEqual $_.Exception.Message.Contains("No graph with name") true
}

Start-Sleep -s 50
Start-TestSleep -s 50

# List graphs
$Listgraphs = Get-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand Down Expand Up @@ -719,13 +719,13 @@ function Test-GremlinInAccountRestoreOperationsSharedRUResourcesCmdlets
$ListDatabases = Get-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListDatabases)

Start-Sleep -s 50
Start-TestSleep -s 50

# Delete the graph
$IsGraphRemoved = Remove-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $graphName -PassThru
Assert-AreEqual $IsGraphRemoved true

Start-Sleep -s 50
Start-TestSleep -s 50

Try {
Restore-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $graphName -RestoreTimestampInUtc $restoreTimestampInUtc
Expand All @@ -738,12 +738,12 @@ function Test-GremlinInAccountRestoreOperationsSharedRUResourcesCmdlets
$IsDatabaseRemoved = Remove-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -PassThru
Assert-AreEqual $IsDatabaseRemoved true

Start-Sleep -s 100
Start-TestSleep -s 100

# Restore the deleted database
Restore-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 100
Start-TestSleep -s 100

# List graphs
$Listgraphs = Get-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand Down
32 changes: 16 additions & 16 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/MongoOperationsTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ Try {
$Lists = Get-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($Lists)

Start-Sleep -s 50
Start-TestSleep -s 50

#delete a Collection
$IsCollectionRemoved = Remove-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName -PassThru
Assert-AreEqual $IsCollectionRemoved true

Start-Sleep -s 100
Start-TestSleep -s 100

Try {
$RestoredCollection = Restore-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName -RestoreTimestampInUtc $restoreTimestampInUtc
Expand All @@ -248,12 +248,12 @@ Try {
$IsRemoved = Remove-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -PassThru
Assert-AreEqual $IsRemoved true

Start-Sleep -s 100
Start-TestSleep -s 100

# restore deleted database
Restore-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 100
Start-TestSleep -s 100

#list all Collections under a database
$ListCollections = Get-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand Down Expand Up @@ -347,18 +347,18 @@ Try {
$Lists = Get-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($Lists)

Start-Sleep -s 50
Start-TestSleep -s 50

#delete a Collection
$IsCollectionRemoved = Remove-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName -PassThru
Assert-AreEqual $IsCollectionRemoved true

Start-Sleep -s 50
Start-TestSleep -s 50

# restore deleted collection
Restore-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 100
Start-TestSleep -s 100

#list all Collections under a database
$ListCollections = Get-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand All @@ -368,7 +368,7 @@ Try {
$IsRemoved = Remove-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -PassThru
Assert-AreEqual $IsRemoved true

Start-Sleep -s 100
Start-TestSleep -s 100

#Restore collection when database is deleted
Try {
Expand All @@ -390,12 +390,12 @@ Try {
# restore deleted database
Restore-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 100
Start-TestSleep -s 100

# restore deleted collection
Restore-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 50
Start-TestSleep -s 50

#list all Collections under a database
$ListCollections = Get-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand Down Expand Up @@ -487,18 +487,18 @@ Try {
$Lists = Get-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($Lists)

Start-Sleep -s 50
Start-TestSleep -s 50

#delete a Collection
$IsCollectionRemoved = Remove-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName -PassThru
Assert-AreEqual $IsCollectionRemoved true

Start-Sleep -s 50
Start-TestSleep -s 50

# restore deleted collection
Restore-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName

Start-Sleep -s 100
Start-TestSleep -s 100

#list all Collections under a database
$ListCollections = Get-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand All @@ -508,12 +508,12 @@ Try {
$IsRemoved = Remove-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -PassThru
Assert-AreEqual $IsRemoved true

Start-Sleep -s 100
Start-TestSleep -s 100

# restore deleted database
Restore-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName

Start-Sleep -s 100
Start-TestSleep -s 100

#list all databases under the account
$Lists = Get-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName
Expand All @@ -527,7 +527,7 @@ Try {
Assert-AreEqual $_.Exception.Message.Contains("No collection with name") true
}

Start-Sleep -s 50
Start-TestSleep -s 50

#delete a database
$IsRemoved = Remove-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -PassThru
Expand Down
26 changes: 13 additions & 13 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/SqlOperationsTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,12 @@ function Test-SqlInAccountRestoreOperationsCmdlets
$ListDatabases = Get-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListDatabases)

Start-Sleep -s 50
Start-TestSleep -s 50

# remove container
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName

Start-Sleep -s 50
Start-TestSleep -s 50

# restore deleted container
Restore-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName -RestoreTimestampInUtc $restoreTimestampInUtc
Expand All @@ -409,7 +409,7 @@ function Test-SqlInAccountRestoreOperationsCmdlets
# remove database
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName

Start-Sleep -s 100
Start-TestSleep -s 100

#Restore collection when database is deleted
Try {
Expand Down Expand Up @@ -437,7 +437,7 @@ function Test-SqlInAccountRestoreOperationsCmdlets
# restore deleted database
Restore-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 50
Start-TestSleep -s 50

# restore deleted container
Restore-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName -RestoreTimestampInUtc $restoreTimestampInUtc
Expand Down Expand Up @@ -573,28 +573,28 @@ function Test-SqlInAccountRestoreOperationsNoTimestampCmdlets
$ListDatabases = Get-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListDatabases)

Start-Sleep -s 50
Start-TestSleep -s 50

# remove container
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName

Start-Sleep -s 50
Start-TestSleep -s 50

# restore deleted container
Restore-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName

Start-Sleep -s 100
Start-TestSleep -s 100

# remove database
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName

Start-Sleep -s 100
Start-TestSleep -s 100


# restore deleted database
Restore-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName

Start-Sleep -s 50
Start-TestSleep -s 50

#Restore collection with no timestamp after database restore
Try {
Expand Down Expand Up @@ -684,12 +684,12 @@ function Test-SqlInAccountRestoreOperationsSharedResourcesCmdlets
$ListDatabases = Get-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListDatabases)

Start-Sleep -s 50
Start-TestSleep -s 50

# remove container
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName

Start-Sleep -s 50
Start-TestSleep -s 50

# restore deleted container
Try {
Expand All @@ -701,7 +701,7 @@ function Test-SqlInAccountRestoreOperationsSharedResourcesCmdlets
# remove database
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName

Start-Sleep -s 100
Start-TestSleep -s 100

$invalidRestoreTimestampInUtc = [DateTime]::UtcNow.ToString('u')
#Restore database with invalid timestamp
Expand All @@ -715,7 +715,7 @@ function Test-SqlInAccountRestoreOperationsSharedResourcesCmdlets
# restore deleted database
Restore-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 50
Start-TestSleep -s 50

# list containers
$ListContainers = Get-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function Test-TableInAccountRestoreOperationsCmdlets
Assert-AreEqual $_.Exception.Message ("Resource with Name " + $TableName + " already exists.")
}

Start-Sleep -s 50
Start-TestSleep -s 50

# get an existing table
$Table = Get-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName
Expand All @@ -283,35 +283,35 @@ function Test-TableInAccountRestoreOperationsCmdlets
$ListTables = Get-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListTables)

Start-Sleep -s 50
Start-TestSleep -s 50

# delete table
$IsTableRemoved = Remove-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName -PassThru
Assert-AreEqual $IsTableRemoved true

Start-Sleep -s 50
Start-TestSleep -s 50

# restore the deleted table
Restore-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName -RestoreTimestampInUtc $restoreTimestampInUtc

Start-Sleep -s 100
Start-TestSleep -s 100

# list tables
$ListTables = Get-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName
Assert-NotNull($ListTables)

Start-Sleep -s 100
Start-TestSleep -s 100

# delete table
$IsTableRemoved = Remove-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName -PassThru
Assert-AreEqual $IsTableRemoved true

Start-Sleep -s 50
Start-TestSleep -s 50

# restore the deleted table
Restore-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName

Start-Sleep -s 100
Start-TestSleep -s 100

# list tables
$ListTables = Get-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName
Expand Down