-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathtask_dump.rs
More file actions
64 lines (54 loc) · 1.99 KB
/
Copy pathtask_dump.rs
File metadata and controls
64 lines (54 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
use base64::prelude::*;
use gateway_messages::SpPort;
use gateway_test_utils::current_simulator_state;
use gateway_test_utils::setup;
use gateway_types::component::SpType;
use gateway_types::task_dump::TaskDump;
use sp_sim::SIM_GIMLET_BOARD;
use std::io::Cursor;
use std::io::Read;
#[tokio::test]
async fn task_dump() {
let testctx = setup::test_setup("task_dump", SpPort::One).await;
let client = &testctx.client;
let simrack = &testctx.simrack;
// sanity check: we have at least 1 gimlet, and all SPs are enabled
let sim_state = current_simulator_state(simrack).await;
assert!(sim_state.iter().any(|sp| sp.ignition.id.typ == SpType::Sled));
assert!(sim_state.iter().all(|sp| sp.state.is_ok()));
// Get task dump count for sled 0.
let resp =
client.sp_task_dump_count(&SpType::Sled, 0).await.unwrap().into_inner();
assert_eq!(resp, 1);
// Get the task dump.
let TaskDump {
task_index,
timestamp,
archive_id,
bord,
gitc,
vers,
base64_zip,
} = client
.sp_task_dump_get(&SpType::Sled, 0, 0)
.await
.unwrap()
.into_inner();
assert_eq!(0, task_index);
assert_eq!(1, timestamp);
assert_eq!(archive_id, "0000000000000000".to_string());
assert_eq!(bord, SIM_GIMLET_BOARD.to_string());
assert_eq!(gitc, "ffffffff".to_string());
assert_eq!(vers, Some("0.0.2".to_string()));
let zip_bytes = BASE64_STANDARD.decode(base64_zip).unwrap();
let cursor = Cursor::new(zip_bytes);
let mut zip = zip::ZipArchive::new(cursor).unwrap();
let mut file = zip.by_name("0x000001.bin").unwrap();
let mut data = Vec::new();
file.read_to_end(&mut data).unwrap();
assert_eq!("my cool SP dump".repeat(3).as_bytes(), data);
testctx.teardown().await;
}