Skip to content

Commit

Permalink
feat: remove last usages of OCKAM_LOG env var
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbenavides committed Nov 14, 2024
1 parent 077a489 commit e4561e4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
1 change: 0 additions & 1 deletion examples/rust/get_started/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub async fn create_token(attribute_name: &str, attribute_value: &str) -> Result
"--attribute",
format!("{attribute_name}={attribute_value}").as_str(),
])
.env_remove("OCKAM_LOG") // make sure that OCKAM_LOG is not set, otherwise the output will contain more than the token
.env_remove("OCKAM_LOGGING") // make sure that OCKAM_LOGGING is not set, otherwise the output will contain more than the token
.output()
.map_err(|e| error(format!("could not run the `ockam project ticket` successfully: {e:?}")))?;
Expand Down
4 changes: 2 additions & 2 deletions implementations/rust/ockam/ockam_api/tests/latency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ockam_transport_core::HostnamePort;
pub fn measure_message_latency_two_nodes() {
let runtime = Arc::new(Runtime::new().unwrap());
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::remove_var("OCKAM_LOG_LEVEL");

let result: ockam::Result<()> = runtime_cloned.block_on(async move {
let test_body = async move {
Expand Down Expand Up @@ -120,7 +120,7 @@ pub fn measure_message_latency_two_nodes() {
pub fn measure_buffer_latency_two_nodes_portal() {
let runtime = Arc::new(Runtime::new().unwrap());
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::remove_var("OCKAM_LOG_LEVEL");

let result: ockam::Result<()> = runtime_cloned.block_on(async move {
let test_body = async move {
Expand Down
8 changes: 4 additions & 4 deletions implementations/rust/ockam/ockam_api/tests/portals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn portal_node_goes_down_reconnect() {
let runtime = Arc::new(Runtime::new().unwrap());
let handle = runtime.handle();
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::remove_var("OCKAM_LOG_LEVEL");

let result: ockam::Result<()> = handle.block_on(async move {
let test_body = async move {
Expand Down Expand Up @@ -238,7 +238,7 @@ fn portal_low_bandwidth_connection_keep_working_for_60s() {
let runtime = Arc::new(Runtime::new().unwrap());
let handle = runtime.handle();
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::remove_var("OCKAM_LOG_LEVEL");

let result: ockam::Result<()> = handle.block_on(async move {
let test_body = async move {
Expand Down Expand Up @@ -359,7 +359,7 @@ fn portal_heavy_load_exchanged() {
let runtime = Arc::new(Runtime::new().unwrap());
let handle = runtime.handle();
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::remove_var("OCKAM_LOG_LEVEL");

let result: ockam::Result<()> = handle.block_on(async move {
let test_body = async move {
Expand Down Expand Up @@ -505,7 +505,7 @@ fn test_portal_payload_transfer(outgoing_disruption: Disruption, incoming_disrup
let runtime = Arc::new(Runtime::new().unwrap());
let handle = runtime.handle();
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::remove_var("OCKAM_LOG_LEVEL");

let result: ockam::Result<_> = handle.block_on(async move {
let test_body = async move {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,9 @@ fn output(mut cont: Container) -> TokenStream {
use ockam_core::{Error, errcode::{Origin, Kind}};
use #ockam_crate::{NodeBuilder, compat::{tokio::time::timeout, futures::FutureExt}};
// don't enable logs in tests by default
use ockam_core::env::get_env;

match get_env::<String>("OCKAM_LOG").unwrap() {
None => std::env::set_var("OCKAM_LOG", "none"),
Some(_) => (),
};
if ockam_core::env::get_env::<String>("OCKAM_LOG_LEVEL").unwrap().is_none() {
std::env::remove_var("OCKAM_LOG_LEVEL");
}

// we don't exit on a panic because we want to catch the panic and report it from within the test.
let (mut #ctx_ident, mut executor) = NodeBuilder::new().no_exit_on_panic().build();
Expand Down
2 changes: 1 addition & 1 deletion implementations/rust/ockam/ockam_node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn setup_tracing() {
use tracing_subscriber::{filter::LevelFilter, fmt, prelude::*, EnvFilter};
static ONCE: std::sync::Once = std::sync::Once::new();
ONCE.call_once(|| {
let filter = EnvFilter::try_from_env("OCKAM_LOG").unwrap_or_else(|_| {
let filter = EnvFilter::try_from_env("OCKAM_LOG_LEVEL").unwrap_or_else(|_| {
EnvFilter::default()
.add_directive(LevelFilter::INFO.into())
.add_directive("ockam_node=info".parse().unwrap())
Expand Down
10 changes: 6 additions & 4 deletions tools/docs/example_test_helper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
//! described by command lines.
//!
//! Processes have these environment variables set...
//! - `OCKAM_LOG=trace`
//! - `OCKAM_LOGGING=true`
//! - `OCKAM_LOG_LEVEL=trace`
//!
//! Some functions will timeout if [`DEFAULT_TIMEOUT_MS`] milliseconds
//! pass. In particular [`CmdBuilder::run()`], but not [`CmdBuilder::spawn()`].
//!
//! Processes which have not completed are killed (or signalled) when their
//! Processes which have not completed are killed (or signaled) when their
//! [`CmdRunner`] is dropped.
//!
//! The stdout of processes are written to temporary files. Those temporary files
//! The stdout of processes is written to temporary files. Those temporary files
//! are left for the operating system to clear up.
//!
//! # Examples
Expand Down Expand Up @@ -57,7 +58,8 @@ use tracing_subscriber::fmt::TestWriter;
use tracing_subscriber::{filter::LevelFilter, fmt, EnvFilter};

const POLL_MS: u32 = 250;
const ENVIRONMENT_VARIABLES: &[(&str, &str)] = &[("OCKAM_LOG", "trace")];
const ENVIRONMENT_VARIABLES: &[(&str, &str)] =
&[("OCKAM_LOGGING", "true"), ("OCKAM_LOG_LEVEL", "trace")];

/// Default timeout value in milliseconds.
pub const DEFAULT_TIMEOUT_MS: u32 = 180_000;
Expand Down
18 changes: 10 additions & 8 deletions tools/stress-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ Options:
To debug failures, you can use:

```
OCKAM_LOG=error stress-test run <config.toml> --log
OCKAM_LOG_LEVEL=error stress-test run <config.toml> --log
```

Sample configuration:

```
peak_portals = 20
peak_relays = 10
Expand All @@ -36,15 +37,16 @@ throughput = "1 mbits"
project = "/project/default"
```

| Parameter | Default | Description | Possible values |
|---------------|------------------|--------------------------------------------------------|------------------------------------------------------------------------------------------|
| peak_portals | 0 | Number of portals to create | positive integers, 1_000 is allowed |
| peak_relays | 0 | Number of relays to create, at least 1 is created | positive integers, 1_000 is allowed |
| ramp_up | 0 | Time, in seconds, to create all the portals and relays | positive integers |
| throughput | unlimited | Throughput to use for each portal | unlimited or positive integer followed by GBits,Mbits,Kbits,Bits, 1_000 Mbits is allowed |
| project | /project/default | Route to any project to test | Any route as long as it reaches a project |
| Parameter | Default | Description | Possible values |
|--------------|------------------|--------------------------------------------------------|------------------------------------------------------------------------------------------|
| peak_portals | 0 | Number of portals to create | positive integers, 1_000 is allowed |
| peak_relays | 0 | Number of relays to create, at least 1 is created | positive integers, 1_000 is allowed |
| ramp_up | 0 | Time, in seconds, to create all the portals and relays | positive integers |
| throughput | unlimited | Throughput to use for each portal | unlimited or positive integer followed by GBits,Mbits,Kbits,Bits, 1_000 Mbits is allowed |
| project | /project/default | Route to any project to test | Any route as long as it reaches a project |

Sample output:

```
| Elapsed | Portals | Relays | M. sent | M. recv | In-fli | B. sent | B. recv | Spe. sent | Spe. recv | M. OOO | Errors |
| 00s | 0 | 0 | 0 | 0 | 0 | 0 B | 0 B | 0.00 bps | 0.00 bps | 0 | 0 |
Expand Down

0 comments on commit e4561e4

Please sign in to comment.