From d58b973f6321ad60b29345f054b6aad146b869d3 Mon Sep 17 00:00:00 2001 From: gurusai-voleti Date: Tue, 30 Dec 2025 08:52:49 +0000 Subject: [PATCH 1/2] chore: Migrate gsutil usage to gcloud storage --- .../SQL2/SQL.GcSqlInstances.Tests.ps1 | 18 +++++++++--------- .../Storage/Storage.GcsBucket.Tests.ps1 | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Google.PowerShell.IntegrationTests/SQL2/SQL.GcSqlInstances.Tests.ps1 b/Google.PowerShell.IntegrationTests/SQL2/SQL.GcSqlInstances.Tests.ps1 index 5eca3dc1..20c33124 100644 --- a/Google.PowerShell.IntegrationTests/SQL2/SQL.GcSqlInstances.Tests.ps1 +++ b/Google.PowerShell.IntegrationTests/SQL2/SQL.GcSqlInstances.Tests.ps1 @@ -169,7 +169,7 @@ Describe "Remove-GcSqlInstance" { Describe "Export-GcSqlInstance" { AfterAll { - gsutil -q rm gs://gcsql-instance-testing/* + gcloud storage rm gs://gcsql-instance-testing/* } # For these tests, test-db4 was used because an instance must have a populated database for it to work. @@ -181,34 +181,34 @@ Describe "Export-GcSqlInstance" { It "should export an applicable SQL file" { - $beforeObjects = gsutil ls gs://gcsql-instance-testing + $beforeObjects = gcloud storage ls gs://gcsql-instance-testing ($beforeObjects -contains "gs://gcsql-instance-testing/testsql$r.gz") | Should Be false Export-GcSqlInstance $instance "gs://gcsql-instance-testing/testsql$r.gz" - $afterObjects = gsutil ls gs://gcsql-instance-testing + $afterObjects = gcloud storage ls gs://gcsql-instance-testing ($afterObjects -contains "gs://gcsql-instance-testing/testsql$r.gz") | Should Be true } It "should export an applicable CSV file" { - $beforeObjects = gsutil ls gs://gcsql-instance-testing + $beforeObjects = gcloud storage ls gs://gcsql-instance-testing ($beforeObjects -contains "gs://gcsql-instance-testing/testcsv$r.csv") | Should Be false Export-GcSqlInstance $instance "gs://gcsql-instance-testing/testcsv$r.csv" "SELECT * FROM guestbook.entries" - $afterObjects = gsutil ls gs://gcsql-instance-testing + $afterObjects = gcloud storage ls gs://gcsql-instance-testing ($afterObjects -contains "gs://gcsql-instance-testing/testcsv$r.csv") | Should Be true } It "should be able to export a specific SQL file" { - $beforeObjects = gsutil ls gs://gcsql-instance-testing + $beforeObjects = gcloud storage ls gs://gcsql-instance-testing ($beforeObjects -contains "gs://gcsql-instance-testing/testothersql$r.gz") | Should Be false Export-GcSqlInstance $instance "gs://gcsql-instance-testing/testothersql$r.gz" -Database "guestbook","guestbook2" - $afterObjects = gsutil ls gs://gcsql-instance-testing + $afterObjects = gcloud storage ls gs://gcsql-instance-testing ($afterObjects -contains "gs://gcsql-instance-testing/testothersql$r.gz") | Should Be true } It "should be able to export a specific CSV file" { - $beforeObjects = gsutil ls gs://gcsql-instance-testing + $beforeObjects = gcloud storage ls gs://gcsql-instance-testing ($beforeObjects -contains "gs://gcsql-instance-testing/testothercsv$r.csv") | Should Be false Export-GcSqlInstance $instance "gs://gcsql-instance-testing/testothercsv$r.csv" -Database "guestbook" "SELECT * FROM entries" - $afterObjects = gsutil ls gs://gcsql-instance-testing + $afterObjects = gcloud storage ls gs://gcsql-instance-testing ($afterObjects -contains "gs://gcsql-instance-testing/testothercsv$r.csv") | Should Be true } diff --git a/Google.PowerShell.IntegrationTests/Storage/Storage.GcsBucket.Tests.ps1 b/Google.PowerShell.IntegrationTests/Storage/Storage.GcsBucket.Tests.ps1 index 966553c5..2aae20cf 100644 --- a/Google.PowerShell.IntegrationTests/Storage/Storage.GcsBucket.Tests.ps1 +++ b/Google.PowerShell.IntegrationTests/Storage/Storage.GcsBucket.Tests.ps1 @@ -28,7 +28,7 @@ Describe "Get-GcsBucket" { } It "should work" { - gsutil mb -p gcloud-powershell-testing gs://gcps-testbucket 2>$null + gcloud storage buckets create gs://gcps-testbucket --project gcloud-powershell-testing 2>$null $bucket = Get-GcsBucket -Name "gcps-testbucket" $bucket.GetType().FullName | Should Match "Google.Apis.Storage.v1.Data.Bucket" @@ -36,7 +36,7 @@ Describe "Get-GcsBucket" { $bucket.Id | Should Match "gcps-testbucket" $bucket.SelfLink | Should Match "https://www.googleapis.com/storage/v1/b/gcps-testbucket" - gsutil rb gs://gcps-testbucket 2>$null + gcloud storage buckets delete gs://gcps-testbucket 2>$null } It "should take into account changes in the Cloud SDK, including environment variables" -Skip:$skipServiceAccountTest { @@ -94,12 +94,12 @@ Describe "New-GcsBucket" { # Should remove the bucket before/after each test to ensure we are in a good state. BeforeEach { - gsutil -m rm -r "gs://gcps-bucket-creation/*" 2>$null - gsutil rb gs://gcps-bucket-creation 2>$null + gcloud storage rm --recursive "gs://gcps-bucket-creation/*" 2>$null + gcloud storage buckets delete gs://gcps-bucket-creation 2>$null } AfterEach { - gsutil rb gs://gcps-bucket-creation 2>$null + gcloud storage buckets delete gs://gcps-bucket-creation 2>$null } It "should work" { @@ -167,7 +167,7 @@ Describe "New-GcsBucket" { { Invoke-WebRequest https://www.googleapis.com/storage/v1/b/gcps-bucket-creation/o/test-obj } | Should Throw "(401) Unauthorized" # But going through gsutil (which passes along your Google credentials) will work. - gsutil cat gs://gcps-bucket-creation/test-obj | Should Be "testing 1, 2, 3..." + gcloud storage cat gs://gcps-bucket-creation/test-obj | Should Be "testing 1, 2, 3..." } } From 80f158dd526a3520f7082d478ac70106540c6f4a Mon Sep 17 00:00:00 2001 From: gurusai-voleti Date: Tue, 30 Dec 2025 10:14:58 +0000 Subject: [PATCH 2/2] chore: migrate gsutil to gcloud --- Google.PowerShell.IntegrationTests/GcloudCmdlets.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Google.PowerShell.IntegrationTests/GcloudCmdlets.ps1 b/Google.PowerShell.IntegrationTests/GcloudCmdlets.ps1 index 6873af4f..01f7d64d 100644 --- a/Google.PowerShell.IntegrationTests/GcloudCmdlets.ps1 +++ b/Google.PowerShell.IntegrationTests/GcloudCmdlets.ps1 @@ -31,16 +31,16 @@ function Install-GcloudCmdlets() { # Creates a GCS bucket owned associated with the project, deleting any existing # buckets with that name and all of their contents. function Create-TestBucket($project, $bucket) { - gsutil -m rm -r "gs://${bucket}/*" 2>$null - gsutil rb "gs://${bucket}" 2>$null - gsutil mb -p $project "gs://${bucket}" 2>$null + gcloud storage rm --recursive "gs://${bucket}/*" 2>$null + gcloud storage bucketes delete "gs://${bucket}" 2>$null + gcloud storage buckets create "gs://${bucket}" --project="$project" 2>$null } # Copies a 0-byte file from the local machine to Google Cloud Storage. function Add-TestFile($bucket, $objName) { $filename = [System.IO.Path]::GetTempFileName() - gsutil ls "gs://${bucket}" 2>$null - gsutil cp $filename "gs://${bucket}/${objName}" 2>$null + gcloud storage ls "gs://${bucket}" 2>$null + gcloud storage cp $filename "gs://${bucket}/${objName}" 2>$null Remove-Item -Force $filename }