From afcff30ce80ed18482cee24986a334b7b2a031b8 Mon Sep 17 00:00:00 2001 From: kazuminn Date: Sun, 18 Sep 2022 17:22:57 +0900 Subject: [PATCH 1/5] auto clear PIVOT_KEYWORE in every unit test --- src/detections/pivot.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/detections/pivot.rs b/src/detections/pivot.rs index af2b0f59..ead8e4f0 100644 --- a/src/detections/pivot.rs +++ b/src/detections/pivot.rs @@ -91,9 +91,9 @@ mod tests { use crate::detections::pivot::PIVOT_KEYWORD; use serde_json; - //PIVOT_KEYWORDはグローバルなので、他の関数の影響も考慮する必要がある。 #[test] fn insert_pivot_keyword_local_ip4() { + PIVOT_KEYWORD.write().unwrap().clear(); load_pivot_keywords("test_files/config/pivot_keywords.txt"); let record_json_str = r#" { @@ -119,6 +119,7 @@ mod tests { #[test] fn insert_pivot_keyword_ip4() { + PIVOT_KEYWORD.write().unwrap().clear(); load_pivot_keywords("test_files/config/pivot_keywords.txt"); let record_json_str = r#" { @@ -144,6 +145,7 @@ mod tests { #[test] fn insert_pivot_keyword_ip_empty() { + PIVOT_KEYWORD.write().unwrap().clear(); load_pivot_keywords("test_files/config/pivot_keywords.txt"); let record_json_str = r#" { @@ -169,6 +171,7 @@ mod tests { #[test] fn insert_pivot_keyword_local_ip6() { + PIVOT_KEYWORD.write().unwrap().clear(); load_pivot_keywords("test_files/config/pivot_keywords.txt"); let record_json_str = r#" { @@ -194,6 +197,7 @@ mod tests { #[test] fn insert_pivot_keyword_level_infomational() { + PIVOT_KEYWORD.write().unwrap().clear(); load_pivot_keywords("test_files/config/pivot_keywords.txt"); let record_json_str = r#" { @@ -219,6 +223,7 @@ mod tests { #[test] fn insert_pivot_keyword_level_low() { + PIVOT_KEYWORD.write().unwrap().clear(); load_pivot_keywords("test_files/config/pivot_keywords.txt"); let record_json_str = r#" { @@ -244,6 +249,7 @@ mod tests { #[test] fn insert_pivot_keyword_level_none() { + PIVOT_KEYWORD.write().unwrap().clear(); load_pivot_keywords("test_files/config/pivot_keywords.txt"); let record_json_str = r#" { From 9c7fa0416db3c6952eb80269607a6e183d159193 Mon Sep 17 00:00:00 2001 From: kazuminn Date: Sun, 18 Sep 2022 18:16:09 +0900 Subject: [PATCH 2/5] add test threads 1 of ci test --- .github/workflows/rust.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f4eb0331..34f2cec8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -35,5 +35,4 @@ jobs: - name: Build run: cargo build --verbose - name: Run tests - run: cargo test --verbose - + run: cargo test --verbose -- --test-threads=1 \ No newline at end of file From 53f232657d0eda351ea77b0ad0c24497aceecb88 Mon Sep 17 00:00:00 2001 From: kazuminn Date: Sun, 18 Sep 2022 18:48:08 +0900 Subject: [PATCH 3/5] add test threads 1 of ci test --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 34f2cec8..efbd6044 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -35,4 +35,4 @@ jobs: - name: Build run: cargo build --verbose - name: Run tests - run: cargo test --verbose -- --test-threads=1 \ No newline at end of file + run: cargo test --verbose -- -- --test-threads=1 \ No newline at end of file From 8f1d31247cc4974253262b43e0921dab4aea86fd Mon Sep 17 00:00:00 2001 From: kazuminn Date: Thu, 22 Sep 2022 11:19:15 +0900 Subject: [PATCH 4/5] add RUST_TEST_THREADS=1 --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index efbd6044..c50e8c73 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -35,4 +35,4 @@ jobs: - name: Build run: cargo build --verbose - name: Run tests - run: cargo test --verbose -- -- --test-threads=1 \ No newline at end of file + run: RUST_TEST_THREADS=1 cargo test --verbose \ No newline at end of file From bef4d080336bd51f41c3e84c5ac05305e0dee12c Mon Sep 17 00:00:00 2001 From: kazuminn Date: Thu, 22 Sep 2022 11:32:07 +0900 Subject: [PATCH 5/5] remove ignore for race_condition test --- src/detections/message.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/detections/message.rs b/src/detections/message.rs index fa374282..74a48783 100644 --- a/src/detections/message.rs +++ b/src/detections/message.rs @@ -625,7 +625,6 @@ mod tests { } } - #[ignore] #[test] fn test_insert_message_race_condition() { MESSAGES.clear();