Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Move x records outputed from smdk test to --verbose #3169 #3234

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/smartmodule-development-kit/src/main.rs
Expand Up @@ -8,8 +8,10 @@ mod hub;
mod set_public;

use std::path::{PathBuf};

use clap::Parser;
TanNgocDo marked this conversation as resolved.
Show resolved Hide resolved
use anyhow::Result;
use tracing::debug;

use cmd::SmdkCommand;

Expand All @@ -23,6 +25,6 @@ fn main() -> Result<()> {
}

pub(crate) fn read_bytes_from_path(path: &PathBuf) -> Result<Vec<u8>> {
println!("loading module at: {}", path.display());
debug!(path = ?path.display(), "Loading module");
std::fs::read(path).map_err(|err| anyhow::anyhow!("error reading wasm file: {}", err))
}
8 changes: 7 additions & 1 deletion crates/smartmodule-development-kit/src/test.rs
Expand Up @@ -66,6 +66,10 @@ pub struct TestCmd {
/// E.g. smdk test --text '{}' --transform='{"uses":"infinyon/jolt@0.1.0","with":{"spec":"[{\"operation\":\"default\",\"spec\":{\"source\":\"test\"}}]"}}'
#[clap(long, short, group = "TestSmartModule")]
transform: Vec<String>,

/// verbose output
#[arg(short = 'v', long = "verbose")]
verbose: bool,
}

fn parse_key_val(s: &str) -> Result<(String, String)> {
Expand Down Expand Up @@ -125,7 +129,9 @@ impl TestCmd {

let output = chain.process(SmartModuleInput::try_from(test_records)?, &metrics)?;

println!("{:?} records outputed", output.successes.len());
if self.verbose {
println!("{:?} records outputed", output.successes.len());
}
for output_record in output.successes {
let output_value = output_record.value.as_str()?;
println!("{output_value}");
Expand Down
46 changes: 30 additions & 16 deletions tests/cli/smdk_smoke_tests/smdk-basic.bats
Expand Up @@ -112,7 +112,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text 'a'
run $SMDK_BIN test --verbose --text 'a'
assert_output --partial "1 records outputed"
assert_success
}
Expand Down Expand Up @@ -152,7 +152,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "4"
assert_success
Expand Down Expand Up @@ -192,12 +192,19 @@ setup_file() {
assert_output --partial "Creating SmartModule: $SM_PACKAGE_NAME"
assert_success

# Test
run $SMDK_BIN test --text '["foo", "bar"]'
# Test with verbose
run $SMDK_BIN test --verbose --text '["foo", "bar"]'
assert_output --partial "2 records outputed"
assert_output --partial "foo"
assert_output --partial "bar"
assert_success

# Test without verbose
run $SMDK_BIN test --text '["foo", "bar"]'
refute_output --partial "2 records outputed"
assert_output --partial "foo"
assert_output --partial "bar"
assert_success
}

@test "Generate and test filter-map - (stable fluvio-smartmodule / no params)" {
Expand Down Expand Up @@ -236,9 +243,9 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "2"
assert_output --partial "1"
assert_success
}

Expand Down Expand Up @@ -277,7 +284,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "2"
assert_success
Expand Down Expand Up @@ -320,7 +327,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text 'a' -e key=value
run $SMDK_BIN test --verbose --text 'a' -e key=value
assert_output --partial "1 records outputed"
assert_success
}
Expand Down Expand Up @@ -502,7 +509,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text 'a'
run $SMDK_BIN test --verbose --text 'a'
assert_output --partial "1 records outputed"
assert_success
}
Expand Down Expand Up @@ -542,7 +549,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "4"
assert_success
Expand Down Expand Up @@ -582,12 +589,19 @@ setup_file() {
assert_output --partial "Creating SmartModule: $SM_PACKAGE_NAME"
assert_success

# Test
run $SMDK_BIN test --text '["foo", "bar"]'
# Test with verbose
run $SMDK_BIN test --verbose --text '["foo", "bar"]'
assert_output --partial "2 records outputed"
assert_output --partial "foo"
assert_output --partial "bar"
assert_success

# Test with without verbose
run $SMDK_BIN test --text '["foo", "bar"]'
refute_output --partial "2 records outputed"
assert_output --partial "foo"
assert_output --partial "bar"
assert_success
}

@test "Generate and test filter-map - (current repo fluvio-smartmodule / no params)" {
Expand Down Expand Up @@ -625,9 +639,9 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "2"
assert_output --partial "1"
assert_success
}

Expand Down Expand Up @@ -666,7 +680,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text '2'
run $SMDK_BIN test --verbose --text '2'
assert_output --partial "1 records outputed"
assert_output --partial "2"
assert_success
Expand Down Expand Up @@ -709,7 +723,7 @@ setup_file() {
assert_success

# Test
run $SMDK_BIN test --text 'a' -e key=value
run $SMDK_BIN test --verbose --text 'a' -e key=value
assert_output --partial "1 records outputed"
assert_success
}
Expand Down