This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git


The following commit(s) were added to refs/heads/develop by this push:
     new 236ebef  [config] Remove inbound from runtime config and update tests 
to use config to get addresses
236ebef is described below

commit 236ebef44f97539d68ec17540253a77fe505678b
Author: Mingshen Sun <[email protected]>
AuthorDate: Sun Feb 9 00:18:44 2020 -0800

    [config] Remove inbound from runtime config and update tests to use config 
to get addresses
---
 config/runtime.config.toml                         | 12 ++++-----
 config/src/runtime.rs                              |  1 -
 .../enclave/src/teaclave_execution_service.rs      | 17 +++++++++---
 .../enclave/src/teaclave_frontend_service.rs       | 13 ++++++++--
 .../enclave/src/teaclave_storage_service.rs        | 30 ++++++++++++----------
 5 files changed, 46 insertions(+), 27 deletions(-)

diff --git a/config/runtime.config.toml b/config/runtime.config.toml
index 0f7cb53..f96e166 100644
--- a/config/runtime.config.toml
+++ b/config/runtime.config.toml
@@ -6,14 +6,14 @@
 
 [api_endpoints]
 authentication = { listen_address = "0.0.0.0:7776" }
-frontend = { listen_address = "0.0.0.0:7777" }
+frontend       = { listen_address = "0.0.0.0:7777" }
 
 [internal_endpoints]
-access_control = { listen_address = "0.0.0.0:7779", advertised_address = 
"localhost:7779" }
-authentication = { listen_address = "0.0.0.0:17776", advertised_address = 
"localhost:17776", inbound_services = ["frontend"] }
-management = { listen_address = "0.0.0.0:17777", advertised_address = 
"localhost:17777" }
-storage = { listen_address = "0.0.0.0:7778", advertised_address = 
"localhost:7778", inbound_services = ["frontend", "management"] }
-execution = { listen_address = "0.0.0.0:7989", advertised_address = 
"localhost:7989" }
+authentication = { listen_address = "0.0.0.0:17776", advertised_address = 
"localhost:17776" }
+management     = { listen_address = "0.0.0.0:17777", advertised_address = 
"localhost:17777" }
+storage        = { listen_address = "0.0.0.0:17778", advertised_address = 
"localhost:17778" }
+access_control = { listen_address = "0.0.0.0:17779", advertised_address = 
"localhost:17779" }
+execution      = { listen_address = "0.0.0.0:17770", advertised_address = 
"localhost:17770" }
 
 [audit]
 enclave_info = { path = "enclave_info.toml" }
diff --git a/config/src/runtime.rs b/config/src/runtime.rs
index f057038..f410f8c 100644
--- a/config/src/runtime.rs
+++ b/config/src/runtime.rs
@@ -47,7 +47,6 @@ pub struct ApiEndpoint {
 pub struct InternalEndpoint {
     pub listen_address: net::SocketAddr,
     pub advertised_address: String,
-    pub inbound_services: Option<Vec<String>>,
 }
 
 #[derive(Debug, Serialize, Deserialize)]
diff --git a/tests/functional_tests/enclave/src/teaclave_execution_service.rs 
b/tests/functional_tests/enclave/src/teaclave_execution_service.rs
index b7059c7..0c4e971 100644
--- a/tests/functional_tests/enclave/src/teaclave_execution_service.rs
+++ b/tests/functional_tests/enclave/src/teaclave_execution_service.rs
@@ -4,6 +4,7 @@ use std::convert::TryInto;
 use teaclave_proto::teaclave_execution_service::*;
 use teaclave_rpc::endpoint::Endpoint;
 
+use teaclave_config::RuntimeConfig;
 use teaclave_types::convert_plaintext_file;
 use teaclave_types::hashmap;
 use teaclave_types::TeaclaveFileCryptoInfo;
@@ -17,13 +18,21 @@ pub fn run_tests() -> bool {
     run_tests!(test_invoke_success,)
 }
 
-fn setup_client() -> TeaclaveExecutionClient {
-    let channel = Endpoint::new("localhost:7989").connect().unwrap();
-    TeaclaveExecutionClient::new(channel).unwrap()
+fn get_client() -> TeaclaveExecutionClient {
+    let runtime_config = 
RuntimeConfig::from_toml("runtime.config.toml").expect("runtime");
+    let channel = Endpoint::new(
+        &runtime_config
+            .internal_endpoints
+            .execution
+            .advertised_address,
+    )
+    .connect()
+    .expect("channel");
+    TeaclaveExecutionClient::new(channel).expect("client")
 }
 
 fn test_invoke_success() {
-    let mut client = setup_client();
+    let mut client = get_client();
 
     let function_args = TeaclaveFunctionArguments::new(&hashmap!(
         "feature_size"  => "4",
diff --git a/tests/functional_tests/enclave/src/teaclave_frontend_service.rs 
b/tests/functional_tests/enclave/src/teaclave_frontend_service.rs
index 516c488..a77e2cb 100644
--- a/tests/functional_tests/enclave/src/teaclave_frontend_service.rs
+++ b/tests/functional_tests/enclave/src/teaclave_frontend_service.rs
@@ -1,5 +1,6 @@
 use std::collections::HashMap;
 use std::prelude::v1::*;
+use teaclave_config::RuntimeConfig;
 use teaclave_proto::teaclave_frontend_service::*;
 use teaclave_rpc::endpoint::Endpoint;
 use teaclave_types::*;
@@ -11,6 +12,15 @@ pub fn run_tests() -> bool {
     run_tests!(test_register_input_file_authentication_error)
 }
 
+fn get_client() -> TeaclaveFrontendClient {
+    let runtime_config = 
RuntimeConfig::from_toml("runtime.config.toml").expect("runtime");
+    let port = &runtime_config.api_endpoints.frontend.listen_address.port();
+    let channel = Endpoint::new(&format!("localhost:{}", port))
+        .connect()
+        .unwrap();
+    TeaclaveFrontendClient::new(channel).unwrap()
+}
+
 fn test_register_input_file_authentication_error() {
     let request = RegisterInputFileRequest {
         url: 
Url::parse("s3://s3.us-west-2.amazonaws.com/mybucket/puppy.jpg.enc?key-id=deadbeefdeadbeef&key=deadbeefdeadbeef").unwrap(),
@@ -25,8 +35,7 @@ fn test_register_input_file_authentication_error() {
     metadata.insert("id".to_string(), "".to_string());
     metadata.insert("token".to_string(), "".to_string());
 
-    let channel = Endpoint::new("localhost:7777").connect().unwrap();
-    let mut client = TeaclaveFrontendClient::new_with_metadata(channel, 
metadata).unwrap();
+    let mut client = get_client();
     let response = client.register_input_file(request);
 
     assert_eq!(
diff --git a/tests/functional_tests/enclave/src/teaclave_storage_service.rs 
b/tests/functional_tests/enclave/src/teaclave_storage_service.rs
index df37a84..e8b39b2 100644
--- a/tests/functional_tests/enclave/src/teaclave_storage_service.rs
+++ b/tests/functional_tests/enclave/src/teaclave_storage_service.rs
@@ -1,4 +1,5 @@
 use std::prelude::v1::*;
+use teaclave_config::RuntimeConfig;
 use teaclave_proto::teaclave_storage_service::*;
 use teaclave_rpc::endpoint::Endpoint;
 
@@ -16,9 +17,16 @@ pub fn run_tests() -> bool {
     )
 }
 
+fn get_client() -> TeaclaveStorageClient {
+    let runtime_config = 
RuntimeConfig::from_toml("runtime.config.toml").expect("runtime");
+    let channel = 
Endpoint::new(&runtime_config.internal_endpoints.storage.advertised_address)
+        .connect()
+        .unwrap();
+    TeaclaveStorageClient::new(channel).unwrap()
+}
+
 fn test_get_success() {
-    let channel = Endpoint::new("localhost:7778").connect().unwrap();
-    let mut client = TeaclaveStorageClient::new(channel).unwrap();
+    let mut client = get_client();
     let request = GetRequest::new("test_get_key");
     let response_result = client.get(request);
     info!("{:?}", response_result);
@@ -26,16 +34,14 @@ fn test_get_success() {
 }
 
 fn test_get_fail() {
-    let channel = Endpoint::new("localhost:7778").connect().unwrap();
-    let mut client = TeaclaveStorageClient::new(channel).unwrap();
+    let mut client = get_client();
     let request = GetRequest::new("test_key_not_exist");
     let response_result = client.get(request);
     assert!(response_result.is_err());
 }
 
 fn test_put_success() {
-    let channel = Endpoint::new("localhost:7778").connect().unwrap();
-    let mut client = TeaclaveStorageClient::new(channel).unwrap();
+    let mut client = get_client();
     let request = PutRequest::new("test_put_key", "test_put_value");
     let response_result = client.put(request);
     info!("{:?}", response_result);
@@ -49,8 +55,7 @@ fn test_put_success() {
 }
 
 fn test_delete_success() {
-    let channel = Endpoint::new("localhost:7778").connect().unwrap();
-    let mut client = TeaclaveStorageClient::new(channel).unwrap();
+    let mut client = get_client();
     let request = DeleteRequest::new("test_delete_key");
     let response_result = client.delete(request);
     info!("{:?}", response_result);
@@ -62,8 +67,7 @@ fn test_delete_success() {
 }
 
 fn test_enqueue_success() {
-    let channel = Endpoint::new("localhost:7778").connect().unwrap();
-    let mut client = TeaclaveStorageClient::new(channel).unwrap();
+    let mut client = get_client();
     let request = EnqueueRequest::new("test_enqueue_key", 
"test_enqueue_value");
     let response_result = client.enqueue(request);
     info!("{:?}", response_result);
@@ -71,8 +75,7 @@ fn test_enqueue_success() {
 }
 
 fn test_dequeue_success() {
-    let channel = Endpoint::new("localhost:7778").connect().unwrap();
-    let mut client = TeaclaveStorageClient::new(channel).unwrap();
+    let mut client = get_client();
     let request = DequeueRequest::new("test_dequeue_key");
     let response_result = client.dequeue(request);
     assert!(response_result.is_err());
@@ -93,8 +96,7 @@ fn test_dequeue_success() {
 }
 
 fn test_dequeue_fail() {
-    let channel = Endpoint::new("localhost:7778").connect().unwrap();
-    let mut client = TeaclaveStorageClient::new(channel).unwrap();
+    let mut client = get_client();
     let request = DequeueRequest::new("test_dequeue_key");
     let response_result = client.dequeue(request);
     assert!(response_result.is_err());


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to