You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by ms...@apache.org on 2020/03/28 06:46:00 UTC

[incubator-teaclave] 02/02: [services] Fix the end_to_end functional test issues

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

commit f0ed34932487903fcc7d219233c1126d4490d381
Author: Mingshen Sun <bo...@mssun.me>
AuthorDate: Fri Mar 27 23:25:48 2020 -0700

    [services] Fix the end_to_end functional test issues
---
 services/execution/enclave/src/service.rs       |  8 ++++----
 services/management/enclave/src/service.rs      |  2 +-
 services/proto/src/teaclave_frontend_service.rs |  6 +++---
 tests/functional/enclave/src/end_to_end.rs      | 14 +++++++-------
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/services/execution/enclave/src/service.rs b/services/execution/enclave/src/service.rs
index 829a7c9..91028ff 100644
--- a/services/execution/enclave/src/service.rs
+++ b/services/execution/enclave/src/service.rs
@@ -83,17 +83,17 @@ impl TeaclaveExecutionService {
             let staged_task = response.staged_task;
             let result = self.invoke_task(&staged_task).unwrap();
             log::debug!("result: {:?}", result);
-            match self.update_task_status(&staged_task.task_id, TaskStatus::Finished) {
+            match self.update_task_result(&staged_task.task_id, result) {
                 Ok(_) => (),
                 Err(e) => {
-                    log::error!("UpdateTask Error: {:?}", e);
+                    log::error!("UpdateResult Error: {:?}", e);
                     continue;
                 }
             }
-            match self.update_task_result(&staged_task.task_id, result) {
+            match self.update_task_status(&staged_task.task_id, TaskStatus::Finished) {
                 Ok(_) => (),
                 Err(e) => {
-                    log::error!("UpdateResult Error: {:?}", e);
+                    log::error!("UpdateTask Error: {:?}", e);
                     continue;
                 }
             }
diff --git a/services/management/enclave/src/service.rs b/services/management/enclave/src/service.rs
index 425a71d..a48968c 100644
--- a/services/management/enclave/src/service.rs
+++ b/services/management/enclave/src/service.rs
@@ -387,7 +387,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
             approved_user_list: task.approved_user_list,
             input_map: task.input_map,
             output_map: task.output_map,
-            return_value: task.return_value,
+            return_value: task.return_value.unwrap_or_default(),
             output_file_hash: task.output_file_hash,
             status: task.status,
         };
diff --git a/services/proto/src/teaclave_frontend_service.rs b/services/proto/src/teaclave_frontend_service.rs
index 29c47e4..261b033 100644
--- a/services/proto/src/teaclave_frontend_service.rs
+++ b/services/proto/src/teaclave_frontend_service.rs
@@ -329,7 +329,7 @@ pub struct GetTaskResponse {
     pub approved_user_list: HashSet<String>,
     pub input_map: HashMap<String, String>,
     pub output_map: HashMap<String, String>,
-    pub return_value: Option<Vec<u8>>,
+    pub return_value: Vec<u8>,
     pub output_file_hash: HashMap<String, String>,
     pub status: TaskStatus,
 }
@@ -976,7 +976,7 @@ impl std::convert::TryFrom<proto::GetTaskResponse> for GetTaskResponse {
             approved_user_list: proto.approved_user_list.into_iter().collect(),
             input_map,
             output_map,
-            return_value: Some(proto.return_value),
+            return_value: proto.return_value,
             output_file_hash: proto.output_file_hash,
             status,
         };
@@ -1005,7 +1005,7 @@ impl From<GetTaskResponse> for proto::GetTaskResponse {
             approved_user_list: response.approved_user_list.into_iter().collect(),
             input_map,
             output_map,
-            return_value: response.return_value.unwrap_or_default(),
+            return_value: response.return_value,
             output_file_hash: response.output_file_hash,
             status,
         }
diff --git a/tests/functional/enclave/src/end_to_end.rs b/tests/functional/enclave/src/end_to_end.rs
index 48cf94d..52aa164 100644
--- a/tests/functional/enclave/src/end_to_end.rs
+++ b/tests/functional/enclave/src/end_to_end.rs
@@ -12,11 +12,11 @@ use teaclave_rpc::config::SgxTrustedTlsClientConfig;
 use teaclave_rpc::endpoint::Endpoint;
 use teaclave_types::*;
 
-static USERNAME: &'static str = "alice";
-static PASSWORD: &'static str = "daHosldOdker0sS";
-static CONFIG_FILE: &'static str = "runtime.config.toml";
-static AUTH_SERVICE_ADDR: &'static str = "localhost:7776";
-static FRONTEND_SERVICE_ADDR: &'static str = "localhost:7777";
+const USERNAME: &str = "alice";
+const PASSWORD: &str = "daHosldOdker0sS";
+const CONFIG_FILE: &str = "runtime.config.toml";
+const AUTH_SERVICE_ADDR: &str = "localhost:7776";
+const FRONTEND_SERVICE_ADDR: &str = "localhost:7777";
 
 pub fn run_tests() -> bool {
     use teaclave_test_utils::*;
@@ -107,8 +107,8 @@ fn test_echo_task() {
         let response = client.get_task(request).unwrap();
         log::info!("Get task: {:?}", response);
         std::thread::sleep(std::time::Duration::from_secs(1));
-        if response.status != TaskStatus::Running {
-            let ret_val = String::from_utf8(response.return_value.unwrap()).unwrap();
+        if response.status == TaskStatus::Finished {
+            let ret_val = String::from_utf8(response.return_value).unwrap();
             log::info!("Task returns: {:?}", ret_val);
             assert_eq!(&ret_val, "Hello From Teaclave!");
             break;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org