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/23 17:23:53 UTC

[incubator-teaclave] branch develop updated (17cbf0c -> 3157295)

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

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


    from 17cbf0c  [common] Enable all unit_test for rusty_leveldb_sgx (#244)
     new 7f60eba  [tests] Make invoke task/pull task as a pair
     new 3157295  [tests] Rename filename teaclave_*_service.rs to *_service.rs

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 services/execution/enclave/src/service.rs          |  16 +--
 tests/functional/enclave/Cargo.toml                |   1 +
 ...ontrol_service.rs => access_control_service.rs} |   0
 ...cation_service.rs => authentication_service.rs} |   0
 ...ave_frontend_service.rs => frontend_service.rs} |   7 ++
 tests/functional/enclave/src/lib.rs                |  25 ++---
 ...management_service.rs => management_service.rs} |  36 +++++++
 tests/functional/enclave/src/scheduler_service.rs  | 112 +++++++++++++++++++++
 ...clave_storage_service.rs => storage_service.rs} |   0
 .../enclave/src/teaclave_scheduler_service.rs      |  88 ----------------
 tests/functional/enclave/src/utils.rs              |  48 +++++++++
 11 files changed, 222 insertions(+), 111 deletions(-)
 rename tests/functional/enclave/src/{teaclave_access_control_service.rs => access_control_service.rs} (100%)
 rename tests/functional/enclave/src/{teaclave_authentication_service.rs => authentication_service.rs} (100%)
 rename tests/functional/enclave/src/{teaclave_frontend_service.rs => frontend_service.rs} (98%)
 rename tests/functional/enclave/src/{teaclave_management_service.rs => management_service.rs} (95%)
 create mode 100644 tests/functional/enclave/src/scheduler_service.rs
 rename tests/functional/enclave/src/{teaclave_storage_service.rs => storage_service.rs} (100%)
 delete mode 100644 tests/functional/enclave/src/teaclave_scheduler_service.rs
 create mode 100644 tests/functional/enclave/src/utils.rs


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


[incubator-teaclave] 02/02: [tests] Rename filename teaclave_*_service.rs to *_service.rs

Posted by ms...@apache.org.
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 3157295b55e6c73cee0091034cdef630cb192b16
Author: Mingshen Sun <bo...@mssun.me>
AuthorDate: Mon Mar 23 10:06:59 2020 -0700

    [tests] Rename filename teaclave_*_service.rs to *_service.rs
---
 ...ontrol_service.rs => access_control_service.rs} |  0
 ...cation_service.rs => authentication_service.rs} |  0
 ...ave_frontend_service.rs => frontend_service.rs} |  0
 tests/functional/enclave/src/lib.rs                | 24 +++++++++++-----------
 ...management_service.rs => management_service.rs} |  0
 ...e_scheduler_service.rs => scheduler_service.rs} |  0
 ...clave_storage_service.rs => storage_service.rs} |  0
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/functional/enclave/src/teaclave_access_control_service.rs b/tests/functional/enclave/src/access_control_service.rs
similarity index 100%
rename from tests/functional/enclave/src/teaclave_access_control_service.rs
rename to tests/functional/enclave/src/access_control_service.rs
diff --git a/tests/functional/enclave/src/teaclave_authentication_service.rs b/tests/functional/enclave/src/authentication_service.rs
similarity index 100%
rename from tests/functional/enclave/src/teaclave_authentication_service.rs
rename to tests/functional/enclave/src/authentication_service.rs
diff --git a/tests/functional/enclave/src/teaclave_frontend_service.rs b/tests/functional/enclave/src/frontend_service.rs
similarity index 100%
rename from tests/functional/enclave/src/teaclave_frontend_service.rs
rename to tests/functional/enclave/src/frontend_service.rs
diff --git a/tests/functional/enclave/src/lib.rs b/tests/functional/enclave/src/lib.rs
index fd4f321..6c42584 100644
--- a/tests/functional/enclave/src/lib.rs
+++ b/tests/functional/enclave/src/lib.rs
@@ -35,23 +35,23 @@ use teaclave_test_utils::check_all_passed;
 use teaclave_types;
 use teaclave_types::TeeServiceResult;
 
-mod teaclave_access_control_service;
-mod teaclave_authentication_service;
-mod teaclave_frontend_service;
-mod teaclave_management_service;
-mod teaclave_scheduler_service;
-mod teaclave_storage_service;
+mod access_control_service;
+mod authentication_service;
+mod frontend_service;
+mod management_service;
+mod scheduler_service;
+mod storage_service;
 mod utils;
 
 #[handle_ecall]
 fn handle_run_test(_: &RunTestInput) -> TeeServiceResult<RunTestOutput> {
     let ret = check_all_passed!(
-        teaclave_access_control_service::run_tests(),
-        teaclave_authentication_service::run_tests(),
-        teaclave_storage_service::run_tests(),
-        teaclave_frontend_service::run_tests(),
-        teaclave_management_service::run_tests(),
-        teaclave_scheduler_service::run_tests(),
+        access_control_service::run_tests(),
+        authentication_service::run_tests(),
+        storage_service::run_tests(),
+        frontend_service::run_tests(),
+        management_service::run_tests(),
+        scheduler_service::run_tests(),
     );
 
     assert_eq!(ret, true);
diff --git a/tests/functional/enclave/src/teaclave_management_service.rs b/tests/functional/enclave/src/management_service.rs
similarity index 100%
rename from tests/functional/enclave/src/teaclave_management_service.rs
rename to tests/functional/enclave/src/management_service.rs
diff --git a/tests/functional/enclave/src/teaclave_scheduler_service.rs b/tests/functional/enclave/src/scheduler_service.rs
similarity index 100%
rename from tests/functional/enclave/src/teaclave_scheduler_service.rs
rename to tests/functional/enclave/src/scheduler_service.rs
diff --git a/tests/functional/enclave/src/teaclave_storage_service.rs b/tests/functional/enclave/src/storage_service.rs
similarity index 100%
rename from tests/functional/enclave/src/teaclave_storage_service.rs
rename to tests/functional/enclave/src/storage_service.rs


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


[incubator-teaclave] 01/02: [tests] Make invoke task/pull task as a pair

Posted by ms...@apache.org.
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 7f60ebaa01036c54bcc753e98810211d0423af79
Author: Mingshen Sun <bo...@mssun.me>
AuthorDate: Sun Mar 22 23:35:42 2020 -0700

    [tests] Make invoke task/pull task as a pair
---
 services/execution/enclave/src/service.rs          | 16 ++--
 tests/functional/enclave/Cargo.toml                |  1 +
 tests/functional/enclave/src/lib.rs                |  1 +
 .../enclave/src/teaclave_frontend_service.rs       |  7 ++
 .../enclave/src/teaclave_management_service.rs     | 36 ++++++++
 .../enclave/src/teaclave_scheduler_service.rs      | 96 ++++++++++++++--------
 tests/functional/enclave/src/utils.rs              | 48 +++++++++++
 7 files changed, 158 insertions(+), 47 deletions(-)

diff --git a/services/execution/enclave/src/service.rs b/services/execution/enclave/src/service.rs
index 11ea963..d3a3c00 100644
--- a/services/execution/enclave/src/service.rs
+++ b/services/execution/enclave/src/service.rs
@@ -15,12 +15,10 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#[cfg(feature = "mesalock_sgx")]
-use std::prelude::v1::*;
-
 use crate::ocall::handle_file_request;
 
 use std::collections::HashMap;
+use std::prelude::v1::*;
 use std::sync::{Arc, SgxMutex as Mutex};
 
 use teaclave_proto::teaclave_scheduler_service::*;
@@ -229,7 +227,6 @@ fn prepare_task(task: &StagedTask) -> StagedFunction {
 #[cfg(feature = "enclave_unit_test")]
 pub mod tests {
     use super::*;
-    use std::collections::HashMap;
     use std::format;
     use teaclave_types::*;
     use url::Url;
@@ -237,16 +234,13 @@ pub mod tests {
 
     pub fn test_invoke_echo() {
         let task_id = Uuid::new_v4();
-        let mut arg_map = HashMap::new();
-        arg_map.insert("message".to_string(), "Hello, Teaclave!".to_string());
-        let input_map = HashMap::new();
-        let output_map = HashMap::new();
+        let function_arguments = FunctionArguments::new(hashmap!(
+            "message" => "Hello, Teaclave!"
+        ));
         let staged_task = StagedTask::new()
             .task_id(task_id)
             .function_name("echo")
-            .function_arguments(arg_map.into())
-            .input_data(input_map)
-            .output_data(output_map);
+            .function_arguments(function_arguments);
 
         let invocation = prepare_task(&staged_task);
 
diff --git a/tests/functional/enclave/Cargo.toml b/tests/functional/enclave/Cargo.toml
index 3a49dde..b98da12 100644
--- a/tests/functional/enclave/Cargo.toml
+++ b/tests/functional/enclave/Cargo.toml
@@ -32,6 +32,7 @@ serde       = { version = "1.0.92" }
 serde_json  = { version = "1.0.39" }
 thiserror   = { version = "1.0.9" }
 url         = { version = "2.1.1" }
+uuid        = { version = "0.8.1", features = ["v4"] }
 
 teaclave_attestation           = { path = "../../../attestation" }
 teaclave_config                = { path = "../../../config" }
diff --git a/tests/functional/enclave/src/lib.rs b/tests/functional/enclave/src/lib.rs
index 891c552..fd4f321 100644
--- a/tests/functional/enclave/src/lib.rs
+++ b/tests/functional/enclave/src/lib.rs
@@ -41,6 +41,7 @@ mod teaclave_frontend_service;
 mod teaclave_management_service;
 mod teaclave_scheduler_service;
 mod teaclave_storage_service;
+mod utils;
 
 #[handle_ecall]
 fn handle_run_test(_: &RunTestInput) -> TeeServiceResult<RunTestOutput> {
diff --git a/tests/functional/enclave/src/teaclave_frontend_service.rs b/tests/functional/enclave/src/teaclave_frontend_service.rs
index c270e12..a4ca896 100644
--- a/tests/functional/enclave/src/teaclave_frontend_service.rs
+++ b/tests/functional/enclave/src/teaclave_frontend_service.rs
@@ -15,6 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use crate::utils::*;
 use std::collections::HashMap;
 use std::prelude::v1::*;
 use teaclave_attestation::verifier;
@@ -23,6 +24,7 @@ use teaclave_config::BUILD_CONFIG;
 use teaclave_proto::teaclave_authentication_service::*;
 use teaclave_proto::teaclave_common::*;
 use teaclave_proto::teaclave_frontend_service::*;
+use teaclave_proto::teaclave_scheduler_service::*;
 use teaclave_rpc::config::SgxTrustedTlsClientConfig;
 use teaclave_rpc::endpoint::Endpoint;
 use teaclave_types::*;
@@ -509,4 +511,9 @@ fn test_invoke_task() {
     let request = GetTaskRequest::new(&task_id);
     let response = client.get_task(request);
     assert_eq!(response.unwrap().status, TaskStatus::Running);
+
+    let request = PullTaskRequest {};
+    let mut scheduler_client = get_scheduler_client();
+    let response = scheduler_client.pull_task(request);
+    assert!(response.is_ok());
 }
diff --git a/tests/functional/enclave/src/teaclave_management_service.rs b/tests/functional/enclave/src/teaclave_management_service.rs
index c3aec68..4863590 100644
--- a/tests/functional/enclave/src/teaclave_management_service.rs
+++ b/tests/functional/enclave/src/teaclave_management_service.rs
@@ -21,6 +21,7 @@ use teaclave_attestation::verifier;
 use teaclave_config::RuntimeConfig;
 use teaclave_config::BUILD_CONFIG;
 use teaclave_proto::teaclave_management_service::*;
+use teaclave_proto::teaclave_scheduler_service::*;
 use teaclave_rpc::config::SgxTrustedTlsClientConfig;
 use teaclave_rpc::endpoint::Endpoint;
 use teaclave_types::*;
@@ -76,6 +77,36 @@ fn get_client(user_id: &str) -> TeaclaveManagementClient {
     TeaclaveManagementClient::new_with_metadata(channel, metadata).unwrap()
 }
 
+fn get_scheduler_client(user_id: &str) -> TeaclaveSchedulerClient {
+    let runtime_config = RuntimeConfig::from_toml("runtime.config.toml").expect("runtime");
+    let enclave_info =
+        EnclaveInfo::from_bytes(&runtime_config.audit.enclave_info_bytes.as_ref().unwrap());
+    let enclave_attr = enclave_info
+        .get_enclave_attr("teaclave_scheduler_service")
+        .expect("scheduler");
+    let config = SgxTrustedTlsClientConfig::new().attestation_report_verifier(
+        vec![enclave_attr],
+        BUILD_CONFIG.as_root_ca_cert,
+        verifier::universal_quote_verifier,
+    );
+
+    let channel = Endpoint::new(
+        &runtime_config
+            .internal_endpoints
+            .scheduler
+            .advertised_address,
+    )
+    .config(config)
+    .connect()
+    .unwrap();
+
+    let mut metadata = HashMap::new();
+    metadata.insert("id".to_string(), user_id.to_string());
+    metadata.insert("token".to_string(), "".to_string());
+
+    TeaclaveSchedulerClient::new_with_metadata(channel, metadata).unwrap()
+}
+
 fn test_register_input_file() {
     let url = Url::parse("s3://s3.us-west-2.amazonaws.com/mybucket/puppy.jpg.enc?key-id=deadbeefdeadbeef&key=deadbeefdeadbeef").unwrap();
     let crypto_info =
@@ -759,4 +790,9 @@ fn test_invoke_task() {
     let request = GetTaskRequest::new(&task_id);
     let response = client2.get_task(request).unwrap();
     assert_eq!(response.status, TaskStatus::Running);
+
+    let request = PullTaskRequest {};
+    let mut scheduler_client = get_scheduler_client("mock_user");
+    let response = scheduler_client.pull_task(request);
+    assert!(response.is_ok());
 }
diff --git a/tests/functional/enclave/src/teaclave_scheduler_service.rs b/tests/functional/enclave/src/teaclave_scheduler_service.rs
index 099fb1a..1aaea6a 100644
--- a/tests/functional/enclave/src/teaclave_scheduler_service.rs
+++ b/tests/functional/enclave/src/teaclave_scheduler_service.rs
@@ -15,62 +15,86 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use crate::utils::*;
 use std::collections::HashMap;
+use std::collections::HashSet;
 use std::prelude::v1::*;
-use teaclave_attestation::verifier;
-use teaclave_config::RuntimeConfig;
-use teaclave_config::BUILD_CONFIG;
 use teaclave_proto::teaclave_scheduler_service::*;
-use teaclave_rpc::config::SgxTrustedTlsClientConfig;
-use teaclave_rpc::endpoint::Endpoint;
+use teaclave_proto::teaclave_storage_service::*;
 use teaclave_types::*;
 
+use uuid::Uuid;
+
 pub fn run_tests() -> bool {
     use teaclave_test_utils::*;
 
     run_tests!(test_pull_task, test_update_task_status_result)
 }
 
-fn get_client(user_id: &str) -> TeaclaveSchedulerClient {
-    let runtime_config = RuntimeConfig::from_toml("runtime.config.toml").expect("runtime");
-    let enclave_info =
-        EnclaveInfo::from_bytes(&runtime_config.audit.enclave_info_bytes.as_ref().unwrap());
-    let enclave_attr = enclave_info
-        .get_enclave_attr("teaclave_scheduler_service")
-        .expect("scheduler");
-    let config = SgxTrustedTlsClientConfig::new().attestation_report_verifier(
-        vec![enclave_attr],
-        BUILD_CONFIG.as_root_ca_cert,
-        verifier::universal_quote_verifier,
-    );
+fn test_pull_task() {
+    let task_id = Uuid::new_v4();
+    let function_id = Uuid::new_v4();
+    let function_name = "echo";
 
-    let channel = Endpoint::new(
-        &runtime_config
-            .internal_endpoints
-            .scheduler
-            .advertised_address,
-    )
-    .config(config)
-    .connect()
-    .unwrap();
-
-    let mut metadata = HashMap::new();
-    metadata.insert("id".to_string(), user_id.to_string());
-    metadata.insert("token".to_string(), "".to_string());
-
-    TeaclaveSchedulerClient::new_with_metadata(channel, metadata).unwrap()
-}
+    let staged_task = StagedTask::new()
+        .task_id(task_id)
+        .function_id(function_id.clone())
+        .function_name(function_name);
 
-fn test_pull_task() {
-    let mut client = get_client("mock_user");
+    let mut storage_client = get_storage_client();
+    let enqueue_request = EnqueueRequest::new(
+        StagedTask::get_queue_key().as_bytes(),
+        staged_task.to_vec().unwrap(),
+    );
+    let _enqueue_response = storage_client.enqueue(enqueue_request).unwrap();
+
+    let mut client = get_scheduler_client();
     let request = PullTaskRequest {};
     let response = client.pull_task(request);
     log::debug!("response: {:?}", response);
     assert!(response.is_ok());
+    assert_eq!(response.unwrap().staged_task.function_id, function_id);
 }
 
 fn test_update_task_status_result() {
-    let mut client = get_client("mock_user");
+    let task_id = Uuid::new_v4();
+
+    let task = Task {
+        task_id,
+        creator: "".to_string(),
+        function_id: "".to_string(),
+        function_owner: "".to_string(),
+        function_arguments: FunctionArguments::default(),
+        input_data_owner_list: HashMap::new(),
+        output_data_owner_list: HashMap::new(),
+        participants: HashSet::new(),
+        approved_user_list: HashSet::new(),
+        input_map: HashMap::new(),
+        output_map: HashMap::new(),
+        return_value: None,
+        output_file_hash: HashMap::new(),
+        status: TaskStatus::Running,
+    };
+
+    let function_id = Uuid::new_v4();
+    let function_name = "echo";
+
+    let staged_task = StagedTask::new()
+        .task_id(task_id.clone())
+        .function_id(function_id)
+        .function_name(function_name);
+
+    let mut storage_client = get_storage_client();
+    let enqueue_request = EnqueueRequest::new(
+        StagedTask::get_queue_key().as_bytes(),
+        staged_task.to_vec().unwrap(),
+    );
+    let _enqueue_response = storage_client.enqueue(enqueue_request).unwrap();
+
+    let put_request = PutRequest::new(task.key().as_slice(), task.to_vec().unwrap().as_slice());
+    let _put_response = storage_client.put(put_request).unwrap();
+
+    let mut client = get_scheduler_client();
     let request = PullTaskRequest {};
     let response = client.pull_task(request).unwrap();
     log::debug!("response: {:?}", response);
diff --git a/tests/functional/enclave/src/utils.rs b/tests/functional/enclave/src/utils.rs
new file mode 100644
index 0000000..cafc469
--- /dev/null
+++ b/tests/functional/enclave/src/utils.rs
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::prelude::v1::*;
+use teaclave_config::RuntimeConfig;
+use teaclave_proto::teaclave_scheduler_service::*;
+use teaclave_proto::teaclave_storage_service::*;
+use teaclave_rpc::endpoint::Endpoint;
+use teaclave_types::*;
+
+pub(crate) fn get_scheduler_client() -> TeaclaveSchedulerClient {
+    let runtime_config = RuntimeConfig::from_toml("runtime.config.toml").expect("runtime");
+    let address = runtime_config
+        .internal_endpoints
+        .scheduler
+        .advertised_address;
+    let channel = Endpoint::new(&address).connect().unwrap();
+    let metadata = hashmap!(
+        "id" => "mock_user",
+        "token" => "",
+    );
+    TeaclaveSchedulerClient::new_with_metadata(channel, metadata).unwrap()
+}
+
+pub(crate) fn get_storage_client() -> TeaclaveStorageClient {
+    let runtime_config = RuntimeConfig::from_toml("runtime.config.toml").expect("runtime");
+    let address = runtime_config.internal_endpoints.storage.advertised_address;
+    let channel = Endpoint::new(&address).connect().unwrap();
+    let metadata = hashmap!(
+        "id" => "mock_user",
+        "token" => "",
+    );
+    TeaclaveStorageClient::new_with_metadata(channel, metadata).unwrap()
+}


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