askill
ordo-testing

ordo-testingSafety 100Repository

Ordo testing and benchmarking guide. Includes unit tests, integration tests, Criterion benchmarks, k6 load tests, CI configuration. Use for writing tests, performance analysis, continuous integration.

32 stars
1.2k downloads
Updated 1/28/2026

Package Files

Loading files...
SKILL.md

Ordo Testing and Benchmarking

Unit Tests

Running Tests

# Run all tests
cargo test

# Run specific crate
cargo test --package ordo-core
cargo test --package ordo-server

# Run specific test
cargo test test_full_workflow

# Show output
cargo test -- --nocapture

# Parallel control
cargo test -- --test-threads=4

Test Example

#[cfg(test)]
mod tests {
    use super::*;
    use ordo_core::prelude::*;

    #[test]
    fn test_rule_execution() {
        let mut ruleset = RuleSet::new("test", "start");
        
        ruleset.add_step(
            Step::decision("start", "Start")
                .branch(Condition::from_string("value > 10"), "high")
                .default("low")
                .build()
        );
        
        ruleset.add_step(Step::terminal("high", "High", 
            TerminalResult::new("HIGH")));
        ruleset.add_step(Step::terminal("low", "Low", 
            TerminalResult::new("LOW")));

        let executor = RuleExecutor::new();
        
        // Test high value
        let input: Value = serde_json::from_str(r#"{"value": 20}"#).unwrap();
        let result = executor.execute(&ruleset, input).unwrap();
        assert_eq!(result.code, "HIGH");
        
        // Test low value
        let input: Value = serde_json::from_str(r#"{"value": 5}"#).unwrap();
        let result = executor.execute(&ruleset, input).unwrap();
        assert_eq!(result.code, "LOW");
    }

    #[test]
    fn test_expression_eval() {
        let evaluator = Evaluator::new();
        let parser = ExprParser::new();
        
        let expr = parser.parse("age >= 18 && status == \"active\"").unwrap();
        let ctx = Context::from_json(r#"{"age": 25, "status": "active"}"#).unwrap();
        let result = evaluator.eval(&expr, &ctx).unwrap();
        
        assert_eq!(result, Value::Bool(true));
    }
}

Integration Tests

gRPC Tests

cargo test --package ordo-server --test grpc_test

UDS Tests

cargo test --package ordo-server --test uds_test

Benchmarks

Running Criterion Benchmarks

# All benchmarks
cargo bench --package ordo-core

# Specific benchmarks
cargo bench --package ordo-core --bench engine_bench
cargo bench --package ordo-core --bench jit_comparison_bench
cargo bench --package ordo-core --bench schema_jit_bench
cargo bench --package ordo-core --bench optimization_bench

Benchmark Files

FileDescription
engine_bench.rsOverall engine performance
jit_comparison_bench.rsJIT vs interpreter comparison
jit_realistic_bench.rsRealistic JIT scenarios
jit_stress_bench.rsJIT stress testing
schema_jit_bench.rsSchema JIT performance
optimization_bench.rsOptimization effectiveness

Writing Benchmarks

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use ordo_core::prelude::*;

fn bench_rule_execution(c: &mut Criterion) {
    let mut ruleset = RuleSet::new("bench", "start");
    // ... setup rules
    
    let executor = RuleExecutor::new();
    let input: Value = serde_json::from_str(r#"{"value": 100}"#).unwrap();
    
    c.bench_function("rule_execution", |b| {
        b.iter(|| {
            executor.execute(&ruleset, black_box(input.clone()))
        })
    });
}

criterion_group!(benches, bench_rule_execution);
criterion_main!(benches);

k6 Load Testing

Running Load Tests

# Basic test
./scripts/benchmark.sh

# Custom parameters
./scripts/benchmark.sh \
    -h localhost \
    -p 8080 \
    -d 60s \
    -u 50 \
    -r 500 \
    --rule order_discount \
    --analyze

Parameter Reference

ParameterDescriptionDefault
-h, --hostServer addresslocalhost
-p, --portPort8080
-d, --durationTest duration30s
-u, --vusVirtual users10
-r, --rpsTarget RPS100
--ruleRule name to testorder_discount
--analyzeShow CPU analysisfalse

Custom k6 Script

import http from 'k6/http';
import { check } from 'k6';

export const options = {
    scenarios: {
        constant_load: {
            executor: 'constant-arrival-rate',
            rate: 100,
            timeUnit: '1s',
            duration: '30s',
            preAllocatedVUs: 10,
        },
    },
    thresholds: {
        http_req_duration: ['p(95)<500', 'p(99)<1000'],
    },
};

export default function() {
    const url = 'http://localhost:8080/api/v1/execute/my-rule';
    const payload = JSON.stringify({
        input: { value: Math.random() * 1000 }
    });
    
    const response = http.post(url, payload, {
        headers: { 'Content-Type': 'application/json' },
    });
    
    check(response, {
        'status is 200': (r) => r.status === 200,
        'response time < 100ms': (r) => r.timings.duration < 100,
    });
}

CI Configuration

GitHub Actions

Key workflow file: .github/workflows/ci.yml

# Test job
test:
  runs-on: ${{ matrix.os }}
  strategy:
    matrix:
      os: [ubuntu-latest, macos-latest, windows-latest]
      rust: [stable, beta]
  steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@master
      with:
        toolchain: ${{ matrix.rust }}
    - run: cargo test --all-features

Local CI Simulation

# Format check
cargo fmt --all -- --check

# Clippy check
cargo clippy --all-targets --all-features -- -D warnings

# Test
cargo test --all-features

# Build
cargo build --release

Test Coverage

# Install tarpaulin
cargo install cargo-tarpaulin

# Generate coverage report
cargo tarpaulin --out Html --output-dir coverage/

# Or use llvm-cov
cargo install cargo-llvm-cov
cargo llvm-cov --html

Frontend Testing

cd ordo-editor

# Run tests
pnpm test

# Run specific package tests
pnpm --filter @ordo-engine/editor-core test

Key Files

  • crates/ordo-core/benches/ - Rust benchmarks
  • crates/ordo-server/tests/ - Server integration tests
  • scripts/benchmark.sh - k6 load test script
  • .github/workflows/ci.yml - CI configuration
  • ordo-editor/packages/core/src/engine/__tests__/ - Frontend tests

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

92/100Analyzed 2/11/2026

A high-quality, comprehensive guide for testing and benchmarking the Ordo project, featuring unit/integration tests, Criterion benchmarks, k6 load testing, and CI configuration.

100
95
60
95
98

Metadata

Licenseunknown
Version-
Updated1/28/2026
PublisherPama-Lee

Tags

apici-cdgithubgithub-actionstesting