From 8ef526f409d4decabecf93496405a22240785d21 Mon Sep 17 00:00:00 2001 From: Sergey Yakubov <sergey.yakubov@desy.de> Date: Mon, 6 Apr 2020 12:49:09 +0200 Subject: [PATCH] update service names --- broker/src/asapo_broker/server/server.go | 2 +- broker/src/asapo_broker/server/server_test.go | 4 ++-- config/nomad/authorizer.nmd.in | 2 +- config/nomad/discovery.nmd.in | 4 ++-- config/nomad/file_transfer.nmd.in | 2 +- consumer/api/cpp/src/server_data_broker.cpp | 6 +++--- .../api/cpp/unittests/test_server_broker.cpp | 8 ++++---- .../asapo_services/scripts/asapo-fts.nmd.tpl | 18 ++++++++--------- .../{fts.json.tpl => file-transfer.json.tpl} | 0 deploy/asapo_services/scripts/nginx.conf.tpl | 8 ++++---- .../cpp/src/receiver_discovery_service.cpp | 2 +- .../test_receiver_discovery_service.cpp | 2 +- receiver/src/request_handler_db.cpp | 2 +- .../unittests/test_request_handler_db.cpp | 4 ++-- tests/automatic/settings/nginx.conf.tpl | 12 +++++------ .../settings/receiver.json.tpl.lin.in | 4 ++-- .../settings/receiver.json.tpl.win.in | 4 ++-- tests/manual/maxwell/asapo_test/clean.sh | 20 +++++++++---------- 18 files changed, 52 insertions(+), 52 deletions(-) rename deploy/asapo_services/scripts/{fts.json.tpl => file-transfer.json.tpl} (100%) diff --git a/broker/src/asapo_broker/server/server.go b/broker/src/asapo_broker/server/server.go index 1f8fe1ce5..cc69db83f 100644 --- a/broker/src/asapo_broker/server/server.go +++ b/broker/src/asapo_broker/server/server.go @@ -42,7 +42,7 @@ type discoveryAPI struct { var discoveryService discoveryAPI func (api *discoveryAPI) GetMongoDbAddress() (string, error) { - resp, err := api.Client.Get(api.baseURL + "/mongo") + resp, err := api.Client.Get(api.baseURL + "/asapo-mongodb") if err != nil { return "", err } diff --git a/broker/src/asapo_broker/server/server_test.go b/broker/src/asapo_broker/server/server_test.go index fc602642e..39967ed75 100644 --- a/broker/src/asapo_broker/server/server_test.go +++ b/broker/src/asapo_broker/server/server_test.go @@ -67,7 +67,7 @@ func TestInitDBWithAutoAddress(t *testing.T) { settings.DatabaseServer = "auto" mock_server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - assert.Equal(t, req.URL.String(), "/mongo", "request string") + assert.Equal(t, req.URL.String(), "/asapo-mongodb", "request string") rw.Write([]byte(mongo_address)) })) defer mock_server.Close() @@ -85,7 +85,7 @@ func TestInitDBWithAutoAddress(t *testing.T) { func TestReconnectDB(t *testing.T) { mongo_address := "0.0.0.0:0000" mock_server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - assert.Equal(t, req.URL.String(), "/mongo", "request string") + assert.Equal(t, req.URL.String(), "/asapo-mongodb", "request string") rw.Write([]byte(mongo_address)) })) discoveryService = discoveryAPI{mock_server.Client(), mock_server.URL} diff --git a/config/nomad/authorizer.nmd.in b/config/nomad/authorizer.nmd.in index 8e90882ea..dfd607246 100644 --- a/config/nomad/authorizer.nmd.in +++ b/config/nomad/authorizer.nmd.in @@ -25,7 +25,7 @@ job "authorizer" { } service { - name = "authorizer" + name = "asapo-authorizer" port = "authorizer" check { name = "alive" diff --git a/config/nomad/discovery.nmd.in b/config/nomad/discovery.nmd.in index cf39f0348..760aed3c7 100644 --- a/config/nomad/discovery.nmd.in +++ b/config/nomad/discovery.nmd.in @@ -25,12 +25,12 @@ job "discovery" { } service { - name = "discovery" + name = "asapo-discovery" port = "discovery" check { name = "alive" type = "http" - path = "/receivers" + path = "/asapo-receiver" interval = "10s" timeout = "2s" initial_status = "passing" diff --git a/config/nomad/file_transfer.nmd.in b/config/nomad/file_transfer.nmd.in index 2ff798a51..f9cdd712f 100644 --- a/config/nomad/file_transfer.nmd.in +++ b/config/nomad/file_transfer.nmd.in @@ -25,7 +25,7 @@ job "file_transfer" { } service { - name = "asapo-fts" + name = "asapo-file-transfer" port = "file_transfer" check { name = "alive" diff --git a/consumer/api/cpp/src/server_data_broker.cpp b/consumer/api/cpp/src/server_data_broker.cpp index 883f32b1e..f8de01a65 100644 --- a/consumer/api/cpp/src/server_data_broker.cpp +++ b/consumer/api/cpp/src/server_data_broker.cpp @@ -14,8 +14,8 @@ using std::chrono::system_clock; namespace asapo { -const std::string ServerDataBroker::kBrokerServiceName = "broker"; -const std::string ServerDataBroker::kFileTransferServiceName = "fts"; +const std::string ServerDataBroker::kBrokerServiceName = "asapo-broker"; +const std::string ServerDataBroker::kFileTransferServiceName = "asapo-file-transfer"; Error GetNoDataResponseFromJson(const std::string& json_string, ConsumerErrorData* data) { JsonStringParser parser(json_string); @@ -598,7 +598,7 @@ Error ServerDataBroker::UpdateFolderTokenIfNeeded(bool ignore_existing) { RequestInfo ServerDataBroker::CreateFolderTokenRequest() const { RequestInfo ri; ri.host = endpoint_; - ri.api = "/authorizer/folder"; + ri.api = "/asapo-authorizer/folder"; ri.post = true; ri.body = "{\"Folder\":\"" + source_path_ + "\",\"BeamtimeId\":\"" + source_credentials_.beamtime_id + "\",\"Token\":\"" + diff --git a/consumer/api/cpp/unittests/test_server_broker.cpp b/consumer/api/cpp/unittests/test_server_broker.cpp index aba9bfe5e..00e26b458 100644 --- a/consumer/api/cpp/unittests/test_server_broker.cpp +++ b/consumer/api/cpp/unittests/test_server_broker.cpp @@ -320,7 +320,7 @@ TEST_F(ServerDataBrokerTests, GetImageReturnsWrongResponseFromHttpClient) { } TEST_F(ServerDataBrokerTests, GetImageReturnsIfBrokerAddressNotFound) { - EXPECT_CALL(mock_http_client, Get_t(HasSubstr(expected_server_uri + "/discovery/broker"), _, + EXPECT_CALL(mock_http_client, Get_t(HasSubstr(expected_server_uri + "/discovery/asapo-broker"), _, _)).Times(AtLeast(2)).WillRepeatedly(DoAll( SetArgPointee<1>(HttpCode::NotFound), SetArgPointee<2>(nullptr), @@ -333,7 +333,7 @@ TEST_F(ServerDataBrokerTests, GetImageReturnsIfBrokerAddressNotFound) { } TEST_F(ServerDataBrokerTests, GetImageReturnsIfBrokerUriEmpty) { - EXPECT_CALL(mock_http_client, Get_t(HasSubstr(expected_server_uri + "/discovery/broker"), _, + EXPECT_CALL(mock_http_client, Get_t(HasSubstr(expected_server_uri + "/discovery/asapo-broker"), _, _)).Times(AtLeast(2)).WillRepeatedly(DoAll( SetArgPointee<1>(HttpCode::OK), SetArgPointee<2>(nullptr), @@ -353,7 +353,7 @@ TEST_F(ServerDataBrokerTests, GetDoNotCallBrokerUriIfAlreadyFound) { data_broker->GetNext(&info, expected_group_id, nullptr); Mock::VerifyAndClearExpectations(&mock_http_client); - EXPECT_CALL(mock_http_client, Get_t(HasSubstr(expected_server_uri + "/discovery/broker"), _, _)).Times(0); + EXPECT_CALL(mock_http_client, Get_t(HasSubstr(expected_server_uri + "/discovery/asap-broker"), _, _)).Times(0); MockGet("error_response"); data_broker->GetNext(&info, expected_group_id, nullptr); } @@ -432,7 +432,7 @@ ACTION(AssignArg2) { TEST_F(ServerDataBrokerTests, GetNextRetriesIfConnectionHttpClientErrorUntilTimeout) { - EXPECT_CALL(mock_http_client, Get_t(HasSubstr(expected_server_uri + "/discovery/broker"), _, + EXPECT_CALL(mock_http_client, Get_t(HasSubstr(expected_server_uri + "/discovery/asapo-broker"), _, _)).Times(AtLeast(2)).WillRepeatedly(DoAll( SetArgPointee<1>(HttpCode::OK), SetArgPointee<2>(nullptr), diff --git a/deploy/asapo_services/scripts/asapo-fts.nmd.tpl b/deploy/asapo_services/scripts/asapo-fts.nmd.tpl index b3bd2c306..9e8f9a2c8 100644 --- a/deploy/asapo_services/scripts/asapo-fts.nmd.tpl +++ b/deploy/asapo_services/scripts/asapo-fts.nmd.tpl @@ -1,4 +1,4 @@ -job "asapo-fts" { +job "asapo-file-transfer" { datacenters = ["dc1"] affinity { attribute = "$${meta.node_group}" @@ -13,8 +13,8 @@ job "asapo-fts" { auto_revert = false } - group "fts" { - count = ${n_fts} + group "file-transfer" { + count = ${n_file-transfer} restart { attempts = 2 interval = "3m" @@ -22,7 +22,7 @@ job "asapo-fts" { mode = "fail" } - task "fts" { + task "file-transfer" { driver = "docker" user = "${asapo_user}" config { @@ -49,15 +49,15 @@ job "asapo-fts" { resources { network { - port "fts" {} + port "file-transfer" {} } } service { - port = "fts" - name = "asapo-fts" + port = "file-transfer" + name = "asapo-file-transfer" check { - name = "asapo-fts-alive" + name = "asapo-file-transfer-alive" type = "http" path = "/health-check" interval = "10s" @@ -71,7 +71,7 @@ job "asapo-fts" { } template { - source = "${scripts_dir}/fts.json.tpl" + source = "${scripts_dir}/file-transfer.json.tpl" destination = "local/config.json" change_mode = "restart" } diff --git a/deploy/asapo_services/scripts/fts.json.tpl b/deploy/asapo_services/scripts/file-transfer.json.tpl similarity index 100% rename from deploy/asapo_services/scripts/fts.json.tpl rename to deploy/asapo_services/scripts/file-transfer.json.tpl diff --git a/deploy/asapo_services/scripts/nginx.conf.tpl b/deploy/asapo_services/scripts/nginx.conf.tpl index b101534de..e0c52d1ed 100644 --- a/deploy/asapo_services/scripts/nginx.conf.tpl +++ b/deploy/asapo_services/scripts/nginx.conf.tpl @@ -46,8 +46,8 @@ http { proxy_pass http://$elasticsearch_endpoint:{{ env "NOMAD_META_elasticsearch_port" }}$uri$is_args$args; } - location /discovery/ { - rewrite ^/discovery(/.*) $1 break; + location /asapo-discovery/ { + rewrite ^/asapo-discovery(/.*) $1 break; proxy_pass http://$discovery_endpoint:{{ env "NOMAD_META_discovery_port" }}$uri$is_args$args; } @@ -68,8 +68,8 @@ http { proxy_pass http://$grafana_endpoint:{{ env "NOMAD_META_grafana_port" }}$uri$is_args$args; } - location /authorizer/ { - rewrite ^/authorizer(/.*) $1 break; + location /asapo-authorizer/ { + rewrite ^/asapo-authorizer(/.*) $1 break; proxy_pass http://$authorizer_endpoint:{{ env "NOMAD_META_authorizer_port" }}$uri$is_args$args; } diff --git a/producer/api/cpp/src/receiver_discovery_service.cpp b/producer/api/cpp/src/receiver_discovery_service.cpp index 2f10a3152..b3526bc36 100644 --- a/producer/api/cpp/src/receiver_discovery_service.cpp +++ b/producer/api/cpp/src/receiver_discovery_service.cpp @@ -9,7 +9,7 @@ namespace asapo { -const std::string ReceiverDiscoveryService::kServiceEndpointSuffix = "/discovery/receivers"; +const std::string ReceiverDiscoveryService::kServiceEndpointSuffix = "/discovery/asapo-receiver"; ReceiverDiscoveryService::ReceiverDiscoveryService(std::string endpoint, uint64_t update_frequency_ms): httpclient__{DefaultHttpClient()}, log__{GetDefaultProducerLogger()}, diff --git a/producer/api/cpp/unittests/test_receiver_discovery_service.cpp b/producer/api/cpp/unittests/test_receiver_discovery_service.cpp index ddf55532f..24ceeb87e 100644 --- a/producer/api/cpp/unittests/test_receiver_discovery_service.cpp +++ b/producer/api/cpp/unittests/test_receiver_discovery_service.cpp @@ -48,7 +48,7 @@ class ReceiversStatusTests : public Test { NiceMock<asapo::MockLogger> mock_logger; NiceMock<MockHttpClient>* mock_http_client; - std::string expected_endpoint{"endpoint/discovery/receivers"}; + std::string expected_endpoint{"endpoint/discovery/asapo-receiver"}; ReceiverDiscoveryService status{"endpoint", 20}; void SetUp() override { diff --git a/receiver/src/request_handler_db.cpp b/receiver/src/request_handler_db.cpp index 2b64f85c0..d543b9dc7 100644 --- a/receiver/src/request_handler_db.cpp +++ b/receiver/src/request_handler_db.cpp @@ -37,7 +37,7 @@ Error RequestHandlerDb::GetDatabaseServerUri(std::string* uri) const { HttpCode code; Error http_err; - *uri = http_client__->Get(GetReceiverConfig()->discovery_server + "/mongo", &code, &http_err); + *uri = http_client__->Get(GetReceiverConfig()->discovery_server + "/asapo-mongodb", &code, &http_err); if (http_err) { log__->Error(std::string{"http error when discover database server "} + " from " + GetReceiverConfig()->discovery_server + " : " + http_err->Explain()); diff --git a/receiver/unittests/test_request_handler_db.cpp b/receiver/unittests/test_request_handler_db.cpp index 1f4dc691c..f1091c3c2 100644 --- a/receiver/unittests/test_request_handler_db.cpp +++ b/receiver/unittests/test_request_handler_db.cpp @@ -95,7 +95,7 @@ class DbHandlerTests : public Test { void DbHandlerTests::MockAuthRequest(bool error, HttpCode code) { if (error) { - EXPECT_CALL(mock_http_client, Get_t(expected_discovery_server + "/mongo", _, _)). + EXPECT_CALL(mock_http_client, Get_t(expected_discovery_server + "/asapo-mongodb", _, _)). WillOnce( DoAll(SetArgPointee<2>(new asapo::SimpleError("http error")), Return("") @@ -105,7 +105,7 @@ void DbHandlerTests::MockAuthRequest(bool error, HttpCode code) { HasSubstr(expected_discovery_server)))); } else { - EXPECT_CALL(mock_http_client, Get_t(expected_discovery_server + "/mongo", _, _)). + EXPECT_CALL(mock_http_client, Get_t(expected_discovery_server + "/asapo-mongodb", _, _)). WillOnce( DoAll( SetArgPointee<1>(code), diff --git a/tests/automatic/settings/nginx.conf.tpl b/tests/automatic/settings/nginx.conf.tpl index 782384a11..b4a518fcd 100644 --- a/tests/automatic/settings/nginx.conf.tpl +++ b/tests/automatic/settings/nginx.conf.tpl @@ -27,8 +27,8 @@ http { resolver 127.0.0.1:8600 valid=1s; server { listen {{ env "NOMAD_PORT_nginx" }}; - set $discovery_endpoint discovery.service.asapo; - set $authorizer_endpoint authorizer.service.asapo; + set $discovery_endpoint asapo-discovery.service.asapo; + set $authorizer_endpoint asapo-authorizer.service.asapo; set $fluentd_endpoint fluentd.service.asapo; set $kibana_endpoint kibana.service.asapo; set $grafana_endpoint grafana.service.asapo; @@ -45,8 +45,8 @@ http { proxy_pass http://$elasticsearch_endpoint:9200$uri$is_args$args; } - location /discovery/ { - rewrite ^/discovery(/.*) $1 break; + location /asapo-discovery/ { + rewrite ^/asapo-discovery(/.*) $1 break; proxy_pass http://$discovery_endpoint:5006$uri$is_args$args; } @@ -67,8 +67,8 @@ http { proxy_pass http://$grafana_endpoint:3000$uri$is_args$args; } - location /authorizer/ { - rewrite ^/authorizer(/.*) $1 break; + location /asapo-authorizer/ { + rewrite ^/asapo-authorizer(/.*) $1 break; proxy_pass http://$authorizer_endpoint:5007$uri$is_args$args; } diff --git a/tests/automatic/settings/receiver.json.tpl.lin.in b/tests/automatic/settings/receiver.json.tpl.lin.in index b91057933..baa9b4b6c 100644 --- a/tests/automatic/settings/receiver.json.tpl.lin.in +++ b/tests/automatic/settings/receiver.json.tpl.lin.in @@ -3,7 +3,7 @@ "PerformanceDbServer":"localhost:8086", "PerformanceDbName": "db_test", "DatabaseServer":"auto", - "DiscoveryServer": "localhost:8400/discovery", + "DiscoveryServer": "localhost:8400/asapo-discovery", "DataServer": { "NThreads": 2, "ListenPort": {{ env "NOMAD_PORT_recv_ds" }} @@ -13,7 +13,7 @@ "SizeGB": 1, "ReservedShare": 10 }, - "AuthorizationServer": "localhost:8400/authorizer", + "AuthorizationServer": "localhost:8400/asapo-authorizer", "AuthorizationInterval": 1000, "ListenPort": {{ env "NOMAD_PORT_recv" }}, "Tag": "{{ env "NOMAD_ADDR_recv" }}", diff --git a/tests/automatic/settings/receiver.json.tpl.win.in b/tests/automatic/settings/receiver.json.tpl.win.in index f46bd5bdf..d18f3b98d 100644 --- a/tests/automatic/settings/receiver.json.tpl.win.in +++ b/tests/automatic/settings/receiver.json.tpl.win.in @@ -3,8 +3,8 @@ "PerformanceDbServer":"localhost:8086", "PerformanceDbName": "db_test", "DatabaseServer":"auto", - "DiscoveryServer": "localhost:8400/discovery", - "AuthorizationServer": "localhost:8400/authorizer", + "DiscoveryServer": "localhost:8400/asapo-discovery", + "AuthorizationServer": "localhost:8400/asapo-authorizer", "AuthorizationInterval": 1000, "ListenPort": {{ env "NOMAD_PORT_recv" }}, "DataServer": { diff --git a/tests/manual/maxwell/asapo_test/clean.sh b/tests/manual/maxwell/asapo_test/clean.sh index 3160c9320..d2ad9ba86 100755 --- a/tests/manual/maxwell/asapo_test/clean.sh +++ b/tests/manual/maxwell/asapo_test/clean.sh @@ -1,12 +1,12 @@ export asapo_host=`cat asapo_host` -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream0 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream1 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream2 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream3 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream4 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream5 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream6 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream7 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/mongo` --eval "db.dropDatabase()" asapo_test_stream8 +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream0 +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream1 +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream2 +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream3 +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream4 +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream5 +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream6 +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream7 +dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream8 -- GitLab