From 28f99019250f9b7c608c6210bf79194215fc08f3 Mon Sep 17 00:00:00 2001 From: Andy Lu Date: Wed, 6 Nov 2024 10:32:35 +0100 Subject: [PATCH] update Mockgcp for sqlinstance, sqluser, and sqldatabse --- mockgcp/mocksql/service.go | 11 +++++++++++ mockgcp/mocksql/sqlinstance.go | 8 +++++++- mockgcp/mocksql/sqluser.go | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mockgcp/mocksql/service.go b/mockgcp/mocksql/service.go index 2b88ec6df10..386c6b6e848 100644 --- a/mockgcp/mocksql/service.go +++ b/mockgcp/mocksql/service.go @@ -82,6 +82,17 @@ func (s *MockService) NewHTTPMux(ctx context.Context, conn *grpc.ClientConn) (ht error.Message = "The Cloud SQL instance does not exist." error.Status = "" } + + for errIdx := range error.Errors { + if strings.HasPrefix(error.Errors[errIdx].Message, "database ") { + error.Errors[errIdx].Message = "Not Found." + error.Errors[errIdx].Reason = "notFound" + } + } + if strings.HasPrefix(error.Message, "database ") { + error.Message = "Not Found" + error.Status = "" + } } } diff --git a/mockgcp/mocksql/sqlinstance.go b/mockgcp/mocksql/sqlinstance.go index 0046d25da16..91d5cab422f 100644 --- a/mockgcp/mocksql/sqlinstance.go +++ b/mockgcp/mocksql/sqlinstance.go @@ -287,7 +287,7 @@ func setDatabaseVersionDefaults(obj *pb.DatabaseInstance) error { switch obj.DatabaseVersion { case pb.SqlDatabaseVersion_MYSQL_5_7: obj.DatabaseInstalledVersion = "MYSQL_5_7_44" - obj.MaintenanceVersion = "MYSQL_5_7_44.R20231105.01_03" + obj.MaintenanceVersion = "MYSQL_5_7_44.R20241020.00_00" obj.UpgradableDatabaseVersions = []*pb.AvailableDatabaseVersion{ { DisplayName: asRef("MySQL 8.0"), @@ -359,6 +359,11 @@ func setDatabaseVersionDefaults(obj *pb.DatabaseInstance) error { MajorVersion: asRef("MYSQL_8_0"), Name: asRef("MYSQL_8_0_37"), }, + { + DisplayName: asRef("MySQL 8.0.39"), + MajorVersion: asRef("MYSQL_8_0"), + Name: asRef("MYSQL_8_0_39"), + }, } case pb.SqlDatabaseVersion_MYSQL_8_0: obj.DatabaseInstalledVersion = "MYSQL_8_0_31" @@ -521,6 +526,7 @@ func populateDefaults(obj *pb.DatabaseInstance) { Entitled: asRef(false), FlagRecommenderEnabled: asRef(false), IndexAdvisorEnabled: asRef(false), + ActiveQueryEnabled: asRef(false), } } else if isPostgres(obj) { obj.GeminiConfig = &pb.GeminiInstanceConfig{ diff --git a/mockgcp/mocksql/sqluser.go b/mockgcp/mocksql/sqluser.go index b71efa47525..0a2b297a483 100644 --- a/mockgcp/mocksql/sqluser.go +++ b/mockgcp/mocksql/sqluser.go @@ -92,6 +92,11 @@ func (s *sqlUsersService) Insert(ctx context.Context, req *pb.SqlUsersInsertRequ obj.Project = name.Project.ID obj.Instance = name.Instance obj.Kind = "sql#user" + if obj.GetPasswordPolicy() == nil { + obj.PasswordPolicy = &pb.UserPasswordValidationPolicy{ + Status: &pb.PasswordStatus{}, + } + } obj.Etag = fields.ComputeWeakEtag(obj)