Skip to content

Commit 9f30c71

Browse files
committed
Merge pull-request #584
2 parents 3b87be0 + 6379497 commit 9f30c71

File tree

26 files changed

+324
-180
lines changed

26 files changed

+324
-180
lines changed

src/init/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async fn main() {
7070
);
7171

7272
const START_PORT: u32 = 3;
73-
const INITIAL_POOL_SIZE: u32 = 1; // start at pool size 1, grow based on manifest/args as necessary (see Reaper)
73+
const INITIAL_POOL_SIZE: u8 = 1; // start at pool size 1, grow based on manifest/args as necessary (see Reaper)
7474
let core_pool = StreamPool::new(
7575
SocketAddress::new_vsock(cid, START_PORT, VMADDR_NO_FLAGS),
7676
INITIAL_POOL_SIZE,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use integration::PIVOT_POOL_SIZE_SUCCESS_FILE;
2+
3+
fn main() {
4+
if std::env::var("POOL_SIZE").is_err() {
5+
panic!("invalid pool size specified")
6+
}
7+
8+
integration::Cli::execute(PIVOT_POOL_SIZE_SUCCESS_FILE);
9+
}

src/integration/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::time::Duration;
99
use borsh::{BorshDeserialize, BorshSerialize};
1010
use qos_core::{
1111
client::SocketClient,
12-
io::{SocketAddress, StreamPool, TimeVal, TimeValLike},
12+
io::{SocketAddress, StreamPool},
1313
parser::{GetParserForOptions, OptionsParser, Parser, Token},
1414
};
1515

@@ -19,12 +19,16 @@ pub const PIVOT_OK_SUCCESS_FILE: &str = "./pivot_ok_works";
1919
pub const PIVOT_OK2_SUCCESS_FILE: &str = "./pivot_ok2_works";
2020
/// Path to the file `pivot_ok3` writes on success for tests.
2121
pub const PIVOT_OK3_SUCCESS_FILE: &str = "./pivot_ok3_works";
22+
/// Path to the file `pivot_pool_size` writes on success for tests.
23+
pub const PIVOT_POOL_SIZE_SUCCESS_FILE: &str = "./pivot_pool_size_works";
2224
/// Path to pivot_ok bin for tests.
2325
pub const PIVOT_OK_PATH: &str = "../target/debug/pivot_ok";
2426
/// Path to pivot_ok2 bin for tests.
2527
pub const PIVOT_OK2_PATH: &str = "../target/debug/pivot_ok2";
2628
/// Path to pivot_ok3 bin for tests.
2729
pub const PIVOT_OK3_PATH: &str = "../target/debug/pivot_ok3";
30+
/// Path to pivot_pool_size bin for tests.
31+
pub const PIVOT_POOL_SIZE_PATH: &str = "../target/debug/pivot_pool_size";
2832
/// Path to pivot loop bin for tests.
2933
pub const PIVOT_LOOP_PATH: &str = "../target/debug/pivot_loop";
3034
/// Path to pivot_abort bin for tests.
@@ -132,7 +136,7 @@ pub struct AdditionProofPayload {
132136
pub async fn wait_for_usock(path: &str) {
133137
let addr = SocketAddress::new_unix(path);
134138
let pool = StreamPool::new(addr, 1).unwrap().shared();
135-
let client = SocketClient::new(pool, TimeVal::milliseconds(50));
139+
let client = SocketClient::new(pool, Duration::from_millis(50));
136140

137141
for _ in 0..50 {
138142
if std::fs::exists(path).unwrap() && client.try_connect().await.is_ok()

src/integration/tests/client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use std::sync::Arc;
1+
use std::{sync::Arc, time::Duration};
22

33
use qos_core::{
44
client::SocketClient,
5-
io::{SocketAddress, StreamPool, TimeVal, TimeValLike},
5+
io::{SocketAddress, StreamPool},
66
server::SocketServerError,
77
server::{RequestProcessor, SocketServer},
88
};
@@ -37,7 +37,7 @@ async fn run_echo_server(
3737
async fn direct_connect_works() {
3838
let socket_path = "/tmp/async_client_test_direct_connect_works.sock";
3939
let socket = SocketAddress::new_unix(socket_path);
40-
let timeout = TimeVal::milliseconds(500);
40+
let timeout = Duration::from_millis(500);
4141
let pool = StreamPool::new(socket, 1)
4242
.expect("unable to create async pool")
4343
.shared();
@@ -54,7 +54,7 @@ async fn direct_connect_works() {
5454
async fn times_out_properly() {
5555
let socket_path = "/tmp/async_client_test_times_out_properly.sock";
5656
let socket = SocketAddress::new_unix(socket_path);
57-
let timeout = TimeVal::milliseconds(500);
57+
let timeout = Duration::from_millis(500);
5858
let pool = StreamPool::new(socket, 1)
5959
.expect("unable to create async pool")
6060
.shared();
@@ -68,7 +68,7 @@ async fn times_out_properly() {
6868
async fn repeat_connect_works() {
6969
let socket_path = "/tmp/async_client_test_repeat_connect_works.sock";
7070
let socket = SocketAddress::new_unix(socket_path);
71-
let timeout = TimeVal::milliseconds(500);
71+
let timeout = Duration::from_millis(500);
7272
let pool = StreamPool::new(socket, 1)
7373
.expect("unable to create async pool")
7474
.shared();

src/integration/tests/enclave_app_client_socket_stress.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use integration::{
77
use qos_core::{
88
client::SocketClient,
99
handles::Handles,
10-
io::{SocketAddress, StreamPool, TimeVal, TimeValLike},
10+
io::{SocketAddress, StreamPool},
1111
protocol::{
1212
msg::ProtocolMsg,
1313
services::boot::{
1414
Manifest, ManifestEnvelope, ManifestSet, Namespace, NitroConfig,
1515
PivotConfig, RestartPolicy, ShareSet,
1616
},
17-
ProtocolError, ProtocolPhase, ENCLAVE_APP_SOCKET_CLIENT_TIMEOUT_SECS,
17+
ProtocolError, ProtocolPhase, INITIAL_CLIENT_TIMEOUT,
1818
},
1919
reaper::{Reaper, REAPER_RESTART_DELAY},
2020
};
@@ -103,7 +103,7 @@ async fn enclave_app_client_socket_stress() {
103103
StreamPool::single(SocketAddress::new_unix(ENCLAVE_SOCK)).unwrap();
104104
let enclave_client = SocketClient::new(
105105
enclave_client_pool.shared(),
106-
TimeVal::seconds(ENCLAVE_APP_SOCKET_CLIENT_TIMEOUT_SECS + 3), // needs to be bigger than the slow request below + some time for recovery
106+
INITIAL_CLIENT_TIMEOUT + Duration::from_secs(3), // needs to be bigger than the slow request below + some time for recovery
107107
);
108108

109109
let app_request =

src/integration/tests/interleaving_socket_stress.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use integration::{
66
};
77
use qos_core::{
88
client::{ClientError, SocketClient},
9-
io::{SocketAddress, StreamPool, TimeVal, TimeValLike},
10-
protocol::ENCLAVE_APP_SOCKET_CLIENT_TIMEOUT_SECS,
9+
io::{SocketAddress, StreamPool},
10+
protocol::INITIAL_CLIENT_TIMEOUT,
1111
};
1212
use qos_test_primitives::ChildWrapper;
1313

@@ -27,12 +27,12 @@ async fn interleaving_socket_stress() {
2727
wait_for_usock(SOCKET_STRESS_SOCK).await;
2828

2929
// needs to be long enough for process exit to register and not cause a timeout
30-
let timeout = TimeVal::seconds(ENCLAVE_APP_SOCKET_CLIENT_TIMEOUT_SECS);
3130
let app_pool =
3231
StreamPool::new(SocketAddress::new_unix(SOCKET_STRESS_SOCK), pool_size)
3332
.unwrap();
3433

35-
let enclave_client = SocketClient::new(app_pool.shared(), timeout);
34+
let enclave_client =
35+
SocketClient::new(app_pool.shared(), INITIAL_CLIENT_TIMEOUT);
3636
let mut tasks = Vec::new();
3737

3838
// wait long enough for app to be running and listening

src/integration/tests/proofs.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use borsh::BorshDeserialize;
44
use integration::{wait_for_usock, PivotProofMsg, PIVOT_PROOF_PATH};
55
use qos_core::{
66
client::SocketClient,
7-
io::{SocketAddress, StreamPool, TimeVal, TimeValLike},
8-
protocol::ENCLAVE_APP_SOCKET_CLIENT_TIMEOUT_SECS,
7+
io::{SocketAddress, StreamPool},
8+
protocol::INITIAL_CLIENT_TIMEOUT,
99
};
1010

1111
use qos_p256::P256Public;
@@ -27,10 +27,8 @@ async fn fetch_and_verify_app_proof() {
2727
StreamPool::single(SocketAddress::new_unix(PROOF_TEST_ENCLAVE_SOCKET))
2828
.unwrap();
2929

30-
let enclave_client = SocketClient::new(
31-
enclave_pool.shared(),
32-
TimeVal::seconds(ENCLAVE_APP_SOCKET_CLIENT_TIMEOUT_SECS),
33-
);
30+
let enclave_client =
31+
SocketClient::new(enclave_pool.shared(), INITIAL_CLIENT_TIMEOUT);
3432

3533
let app_request =
3634
borsh::to_vec(&PivotProofMsg::AdditionRequest { a: 2, b: 2 }).unwrap();

0 commit comments

Comments
 (0)