Skip to content
This repository has been archived by the owner on Mar 2, 2020. It is now read-only.

Commit

Permalink
Adjust test data to work together
Browse files Browse the repository at this point in the history
The FTL database query IDs were normalized, and the in memory test
queries were adjusted to better mirror a real-world scenario with the
database (IDs are consistent).

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
  • Loading branch information
AzureMarker committed Jan 12, 2019
1 parent ffeec90 commit 4204b78
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/routes/stats/history/filters/time.rs
Expand Up @@ -50,7 +50,7 @@ mod test {
let filtered_queries: Vec<&FtlQuery> = filter_time_from(
Box::new(queries.iter()),
&HistoryParams {
from: Some(4),
from: Some(177184),
..HistoryParams::default()
}
)
Expand All @@ -67,7 +67,7 @@ mod test {
let filtered_queries: Vec<&FtlQuery> = filter_time_until(
Box::new(queries.iter()),
&HistoryParams {
until: Some(4),
until: Some(177184),
..HistoryParams::default()
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/routes/stats/history/get_history.rs
Expand Up @@ -184,7 +184,7 @@ mod test {
.ftl_memory(ftl_memory)
.expect_json(json!({
"history": history,
"cursor": "eyJpZCI6bnVsbCwiZGJfaWQiOjN9"
"cursor": "eyJpZCI6bnVsbCwiZGJfaWQiOjk3fQ=="
}))
.test();
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/stats/history/map_query_to_json.rs
Expand Up @@ -71,7 +71,7 @@ mod test {
assert_eq!(
mapped_query,
json!({
"timestamp": 1,
"timestamp": 177181,
"type": 1,
"status": 2,
"domain": "domain1.com",
Expand Down
2 changes: 1 addition & 1 deletion src/routes/stats/history/skip_to_cursor.rs
Expand Up @@ -70,7 +70,7 @@ mod test {
&HistoryParams {
cursor: Some(HistoryCursor {
id: None,
db_id: Some(5)
db_id: Some(99)
}),
..HistoryParams::default()
}
Expand Down
46 changes: 24 additions & 22 deletions src/routes/stats/history/testing.rs
Expand Up @@ -63,26 +63,28 @@ pub fn test_memory() -> FtlMemory {
}

/// 9 queries. Query 9 is private. Last two are not in the database. Query 1
/// has a DNSSEC type of Secure and a reply type of CNAME.
/// has a DNSSEC type of Secure and a reply type of CNAME. The database
/// timestamps end at 177180, so the in memory queries start at 177181. The
/// database ids end at 94, so the in memory database IDs start at 95.
///
/// | ID | DB | Type | Status | Domain | Client | Upstream | Timestamp |
/// | -- | -- | ---- | ---------- | ------ | ------ | -------- | --------- |
/// | 1 | 1 | A | Forward | 0 | 0 | 0 | 1 |
/// | 2 | 2 | AAAA | Forward | 0 | 0 | 0 | 2 |
/// | 3 | 3 | PTR | Forward | 0 | 0 | 0 | 3 |
/// | 4 | 4 | A | Gravity | 1 | 1 | 0 | 3 |
/// | 5 | 5 | AAAA | Cache | 0 | 1 | 0 | 4 |
/// | 6 | 6 | AAAA | Wildcard | 2 | 1 | 0 | 5 |
/// | 7 | 7 | A | Blacklist | 3 | 2 | 0 | 5 |
/// | 8 | 0 | AAAA | ExternalB. | 4 | 2 | 1 | 6 |
/// | 9 | 0 | A | Forward | 5 | 3 | 0 | 7 |
/// | ID | DB | Type | Status | Domain | Client | Upstream | Timestamp |
/// | -- | --- | ---- | ---------- | ------ | ------ | -------- | --------- |
/// | 1 | 95 | A | Forward | 0 | 0 | 0 | 177181 |
/// | 2 | 96 | AAAA | Forward | 0 | 0 | 0 | 177182 |
/// | 3 | 97 | PTR | Forward | 0 | 0 | 0 | 177183 |
/// | 4 | 98 | A | Gravity | 1 | 1 | 0 | 177183 |
/// | 5 | 99 | AAAA | Cache | 0 | 1 | 0 | 177184 |
/// | 6 | 100 | AAAA | Wildcard | 2 | 1 | 0 | 177185 |
/// | 7 | 101 | A | Blacklist | 3 | 2 | 0 | 177185 |
/// | 8 | 0 | AAAA | ExternalB. | 4 | 2 | 1 | 177186 |
/// | 9 | 0 | A | Forward | 5 | 3 | 0 | 177187 |
pub fn test_queries() -> Vec<FtlQuery> {
vec![
FtlQuery {
magic: MAGIC_BYTE,
id: 1,
database_id: 1,
timestamp: 1,
database_id: 95,
timestamp: 177181,
time_index: 1,
response_time: 1,
domain_id: 0,
Expand All @@ -96,14 +98,14 @@ pub fn test_queries() -> Vec<FtlQuery> {
is_private: false,
ad_bit: false
},
query!(2, 2, AAAA, Forward, 0, 0, 0, 2, false),
query!(3, 3, PTR, Forward, 0, 0, 0, 3, false),
query!(4, 4, A, Gravity, 1, 1, 0, 3, false),
query!(5, 5, AAAA, Cache, 0, 1, 0, 4, false),
query!(6, 6, AAAA, Wildcard, 2, 1, 0, 5, false),
query!(7, 7, A, Blacklist, 3, 2, 0, 5, false),
query!(8, 0, AAAA, ExternalBlock, 4, 2, 1, 6, false),
query!(9, 0, A, Forward, 5, 3, 0, 7, true),
query!(2, 96, AAAA, Forward, 0, 0, 0, 177182, false),
query!(3, 97, PTR, Forward, 0, 0, 0, 177183, false),
query!(4, 98, A, Gravity, 1, 1, 0, 177183, false),
query!(5, 99, AAAA, Cache, 0, 1, 0, 177184, false),
query!(6, 100, AAAA, Wildcard, 2, 1, 0, 177185, false),
query!(7, 101, A, Blacklist, 3, 2, 0, 177185, false),
query!(8, 0, AAAA, ExternalBlock, 4, 2, 1, 177186, false),
query!(9, 0, A, Forward, 5, 3, 0, 177187, true),
]
}

Expand Down
Binary file modified test/FTL.db
Binary file not shown.

0 comments on commit 4204b78

Please sign in to comment.