diff --git a/cmd/validator/main.go b/cmd/validator/main.go index f0443b0..6aaec04 100644 --- a/cmd/validator/main.go +++ b/cmd/validator/main.go @@ -79,12 +79,8 @@ func loadConfig() (*models.Config, error) { Issuer: os.Getenv("JWT_ISSUER"), }, Database: mongo.Configuration{ - Host: os.Getenv("MONGO_HOST"), - Port: os.Getenv("MONGO_PORT"), - User: os.Getenv("MONGO_USER"), - Password: os.Getenv("MONGO_PASSWORD"), + URL: os.Getenv("MONGO_URL"), DatabaseName: os.Getenv("MONGO_DB_NAME"), - Auth: os.Getenv("MONGO_AUTH"), }, MailClientCfg: models.MailClientCfg{ ApiUrl: os.Getenv("API_URL"), @@ -268,24 +264,12 @@ type t struct { // todo в будущем в монге будут запрещены некоторые операции, надо будет обновлять func validateMongo(cfg mongo.Configuration) error { - if cfg.Host == "" { - return fmt.Errorf("mongo host is empty") - } - if cfg.Port == "" { - return fmt.Errorf("mongo port is empty") + if cfg.URL == "" { + return fmt.Errorf("mongo URL is empty") } if cfg.DatabaseName == "" { return fmt.Errorf("mongo database name is empty") } - if cfg.Auth == "" { - return fmt.Errorf("mongo database auth is empty") - } - if cfg.User == "" { - return fmt.Errorf("mongo database user is empty") - } - if cfg.Password == "" { - return fmt.Errorf("mongo database password is empty") - } cfg.DatabaseName = "testDBName" ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) diff --git a/cmd/validator/main_test.go b/cmd/validator/main_test.go index ebc50f7..968f3c3 100644 --- a/cmd/validator/main_test.go +++ b/cmd/validator/main_test.go @@ -49,12 +49,8 @@ func TestValidateURLs(t *testing.T) { func TestValidateMongo(t *testing.T) { err := validateMongo(mongo.Configuration{ - Host: "localhost", - Port: "27020", - User: "test", - Password: "test", + URL: "mongodb://localhost:27017,localhost:27018,localhost:27019/?replicaSet=rs0&readPreference=primary&ssl=false", DatabaseName: "admin", - Auth: "admin", }) assert.NoError(t, err) } @@ -109,12 +105,8 @@ func TestLoadConfig(t *testing.T) { "GRPC_HOST": "0.0.0.0", "GRPC_PORT": "9001", "GRPC_DOMEN": "customer-service:9000", - "MONGO_HOST": "localhost", - "MONGO_PORT": "27020", - "MONGO_USER": "test", - "MONGO_PASSWORD": "test", + "MONGO_URL": "mongodb://test:test@localhost:27020/", "MONGO_DB_NAME": "admin", - "MONGO_AUTH": "admin", "KAFKA_BROKERS": "localhost:9092", "KAFKA_TOPIC_TARIFF": "test-topic", "AUTH_MICROSERVICE_URL": "http://localhost:8000/user", diff --git a/deployments/staging/docker-compose.yaml b/deployments/staging/docker-compose.yaml index 65434ce..8fd949d 100644 --- a/deployments/staging/docker-compose.yaml +++ b/deployments/staging/docker-compose.yaml @@ -18,12 +18,13 @@ services: - GRPC_PORT=9065 - GRPC_DOMEN=10.8.0.6:9060 - - MONGO_HOST=10.7.0.4 - - MONGO_PORT=27017 - - MONGO_USER=$MONGO_USER - - MONGO_PASSWORD=$MONGO_PASSWORD +# - MONGO_HOST=10.7.0.4 +# - MONGO_PORT=27017 +# - MONGO_USER=$MONGO_USER +# - MONGO_PASSWORD=$MONGO_PASSWORD + - MONGO_URL = TODO - MONGO_DB_NAME=customer - - MONGO_AUTH=customer +# - MONGO_AUTH=customer - NOTIFICATION_RS_PAY_CHANNEL=-1002338593104 - KAFKA_BROKERS=10.8.0.6:9092 diff --git a/go.mod b/go.mod index e7da33a..b9559fa 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23.2 toolchain go1.23.3 require ( - gitea.pena/PenaSide/common v0.0.0-20241126121130-cf56ae1e3fb2 + gitea.pena/PenaSide/common v0.0.0-20241128160655-fe730a08b5f1 gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a gitea.pena/PenaSide/trashlog v0.0.0-20241119225515-2fd267647ca4 github.com/caarlos0/env/v8 v8.0.0 diff --git a/go.sum b/go.sum index edf27c0..fb0b8b3 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,10 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= gitea.pena/PenaSide/common v0.0.0-20241126121130-cf56ae1e3fb2 h1:9U9JJBwWtQV4z/PUCUWCFKurk7sHrT59fGSoXobSdL0= gitea.pena/PenaSide/common v0.0.0-20241126121130-cf56ae1e3fb2/go.mod h1:l71j3W1yROhOSfjWZ6wcMuzjBR37gu2ZTcXsorEJoiw= +gitea.pena/PenaSide/common v0.0.0-20241128144932-b14c114d2569 h1:4PJsYkPNmbpcLAhAHh/jUCJMUwGmGscZ0r9rZeOb30I= +gitea.pena/PenaSide/common v0.0.0-20241128144932-b14c114d2569/go.mod h1:l71j3W1yROhOSfjWZ6wcMuzjBR37gu2ZTcXsorEJoiw= +gitea.pena/PenaSide/common v0.0.0-20241128160655-fe730a08b5f1 h1:w1AAxrlZGmxUI9NAa/0TYsc6sqWWF9yAzQaLL/KxwrM= +gitea.pena/PenaSide/common v0.0.0-20241128160655-fe730a08b5f1/go.mod h1:l71j3W1yROhOSfjWZ6wcMuzjBR37gu2ZTcXsorEJoiw= gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a h1:UySqMgaOKNsR42Y6GQXoM2wn/waYNc9cakMUSvbEEAg= gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a/go.mod h1:gdd+vOT6up9STkEbxa2qESLIMZFjCmRbkcheFQCVgZU= gitea.pena/PenaSide/trashlog v0.0.0-20241119225515-2fd267647ca4 h1:y9B4CSPIgiUoaXKyXLZxs1A9hxzDj26F9MH2R6uTkHQ= diff --git a/internal/initialize/config_test.go b/internal/initialize/config_test.go index 81ffdd7..59472de 100644 --- a/internal/initialize/config_test.go +++ b/internal/initialize/config_test.go @@ -81,11 +81,7 @@ func setDefaultTestingENV(t *testing.T) *models.Config { ExpiresIn: 15 * time.Minute, }, Database: mongo.Configuration{ - Host: "localhost", - Port: "27017", - User: "user", - Password: "pass", - Auth: "db", + URL: "mongodb://test:test@localhost:27020/", DatabaseName: "db", }, }, @@ -111,11 +107,7 @@ func setDefaultTestingENV(t *testing.T) *models.Config { t.Setenv("VERIFICATION_MICROSERVICE_URL", defaultConfiguration.VerificationMicroservice) t.Setenv("TEMPLATEGEN_MICROSERVICE_URL", defaultConfiguration.TemplategenMicroserviceURL) - t.Setenv("MONGO_HOST", defaultConfiguration.ExternalCfg.Database.Host) - t.Setenv("MONGO_PORT", defaultConfiguration.ExternalCfg.Database.Port) - t.Setenv("MONGO_USER", defaultConfiguration.ExternalCfg.Database.User) - t.Setenv("MONGO_PASSWORD", defaultConfiguration.ExternalCfg.Database.Password) - t.Setenv("MONGO_AUTH", defaultConfiguration.ExternalCfg.Database.Auth) + t.Setenv("MONGO_URL", defaultConfiguration.ExternalCfg.Database.URL) t.Setenv("MONGO_DB_NAME", defaultConfiguration.ExternalCfg.Database.DatabaseName) return &defaultConfiguration diff --git a/tests/integration/promo_ltv_test.go b/tests/integration/promo_ltv_test.go index 115e53e..3fbc9d9 100644 --- a/tests/integration/promo_ltv_test.go +++ b/tests/integration/promo_ltv_test.go @@ -3,13 +3,13 @@ package integration import ( "context" "fmt" - "github.com/stretchr/testify/assert" - "go.uber.org/zap" - "log" "gitea.pena/PenaSide/common/mongo" "gitea.pena/PenaSide/customer/internal/interface/client" "gitea.pena/PenaSide/customer/internal/interface/repository" codeword_rpc "gitea.pena/PenaSide/customer/internal/proto/codeword" + "github.com/stretchr/testify/assert" + "go.uber.org/zap" + "log" "testing" "time" ) @@ -29,11 +29,7 @@ func Test_PromoLTV(t *testing.T) { mdb, err := mongo.Connect(ctx, &mongo.ConnectDeps{ Configuration: &mongo.Configuration{ - Host: "localhost", - Port: "27020", - User: "test", - Password: "test", - Auth: "admin", + URL: "mongodb://test:test@localhost:27020/", DatabaseName: "admin", }, Timeout: 10 * time.Second,