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

ci: run cargo test #11

Merged
merged 3 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ on:
tags:
- 'v*'


jobs:
CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install Rust
run: |
git submodule update --init --recursive
rustup toolchain install stable --component clippy --component rustfmt
- name: Format
run: cargo fmt -- --check
- name: clippy
run: cargo clippy
with:
submodules: 'recursive'
- name: Install Rust toolchain
run: rustup toolchain install stable --component clippy --component rustfmt
- name: Run format
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --workspace --tests -- -D warnings
- name: Run tests
run: cargo test --workspace
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
pip3 install --upgrade pip
pip3 install setuptools
pip3 install -r requirements.txt
python3 tests/e2e/run_e2e.py --expected_file=tests/e2e/data/expected_context.yaml --max_retry_times=3 --target_path=/ping
python3 e2e/run_e2e.py --expected_file=e2e/data/expected_context.yaml --max_retry_times=3 --target_path=/ping
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target
/tests/e2e/target
/tests/target
.idea/
4 changes: 2 additions & 2 deletions docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
consumer:
build:
context: .
dockerfile: ./tests/e2e/docker/Dockerfile
dockerfile: ./e2e/docker/Dockerfile
expose:
- 8082
command: --mode consumer
Expand All @@ -28,7 +28,7 @@ services:
producer:
build:
context: .
dockerfile: ./tests/e2e/docker/Dockerfile
dockerfile: ./e2e/docker/Dockerfile
ports:
- "8081:8081"
command: --mode producer
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/e2e/Cargo.toml → e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Shikugawa <Shikugawa@gmail.com>"]
edition = "2021"

[dependencies]
skywalking_rust = { path = "../.." }
skywalking_rust = { path = ".." }
hyper = { version = "0.14", features = ["full"] }
tokio = { version = "1", features = ["full"] }
structopt = "0.3"
File renamed without changes.
5 changes: 5 additions & 0 deletions e2e/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM rust:1.57
WORKDIR /build
COPY . /build/
RUN cd e2e && cargo build --release --locked
ENTRYPOINT ["/build/e2e/target/release/e2e"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/reporter/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ impl Reporter {
/// # Example
///
/// ```no_run
/// use std::error::Error;
///
/// use tokio;
///
/// use skywalking_rust::context::trace_context::TracingContext;
/// use skywalking_rust::reporter::grpc::Reporter;
///
Expand Down
5 changes: 0 additions & 5 deletions tests/e2e/docker/Dockerfile

This file was deleted.

10 changes: 5 additions & 5 deletions tests/propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn basic() {
let data = "1-MQ==-NQ==-3-bWVzaA==-aW5zdGFuY2U=-L2FwaS92MS9oZWFsdGg=-ZXhhbXBsZS5jb206ODA4MA==";
let res = decode_propagation(data).unwrap();

assert_eq!(res.do_sample, true);
assert!(res.do_sample);
assert_eq!(res.parent_trace_id, "1");
assert_eq!(res.parent_trace_segment_id, "5");
assert_eq!(res.parent_span_id, 3);
Expand All @@ -50,23 +50,23 @@ fn less_field() {
let data = "1-MQ==-NQ==-3-bWVzaA==-aW5zdGFuY2U=-L2FwaS92MS9oZWFsdGg=";
let res = decode_propagation(data);

assert_eq!(res.is_err(), true);
assert!(res.is_err());
}

#[test]
fn more_field() {
let data = "1-MQ==-NQ==-3-bWVzaA==-aW5zdGFuY2U=-L2FwaS92MS9oZWFsdGg=-ZXhhbXBsZS5jb206ODA4MA==-hogehoge";
let res = decode_propagation(data);

assert_eq!(res.is_err(), true);
assert!(res.is_err());
}

#[test]
fn invalid_sample() {
let data = "3-MQ==-NQ==-3-bWVzaA==-aW5zdGFuY2U=-L2FwaS92MS9oZWFsdGg=-ZXhhbXBsZS5jb206ODA4MA==";
let res = decode_propagation(data);

assert_eq!(res.is_err(), true);
assert!(res.is_err());
}

#[test]
Expand All @@ -75,7 +75,7 @@ fn basic_encode() {
let tc = TracingContext::default_internal(Arc::new(time_fetcher), "mesh", "instance");
let res = encode_propagation(&tc, "/api/v1/health", "example.com:8080");
let res2 = decode_propagation(&res).unwrap();
assert_eq!(true, res2.do_sample);
assert!(res2.do_sample);
assert_eq!("/api/v1/health", res2.destination_endpoint);
assert_eq!("example.com:8080", res2.destination_address)
}
28 changes: 12 additions & 16 deletions tests/trace_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ fn create_span() {

{
let mut span1 = context.create_entry_span("op1").unwrap();
let mut logs = Vec::<(&str, &str)>::new();
logs.push(("hoge", "fuga"));
logs.push(("hoge2", "fuga2"));
let logs = vec![("hoge", "fuga"), ("hoge2", "fuga2")];
let expected_log_message = logs
.to_owned()
.into_iter()
Expand All @@ -80,15 +78,13 @@ fn create_span() {
}
})
.collect();
let mut expected_log = Vec::<Log>::new();
expected_log.push(Log {
let expected_log = vec![Log {
time: 100,
data: expected_log_message,
});
}];
span1.add_log(logs);

let mut tags = Vec::<(&str, &str)>::new();
tags.push(("hoge", "fuga"));
let tags = vec![("hoge", "fuga")];
let expected_tags = tags
.to_owned()
.into_iter()
Expand All @@ -100,7 +96,7 @@ fn create_span() {
}
})
.collect();
span1.add_tag(tags[0].clone());
span1.add_tag(tags[0]);

let span1_expected = SpanObject {
span_id: 1,
Expand All @@ -124,7 +120,7 @@ fn create_span() {

{
let span2 = context.create_entry_span("op2");
assert_eq!(span2.is_err(), true);
assert!(span2.is_err());
}

{
Expand All @@ -150,11 +146,11 @@ fn create_span() {
}

let segment = context.convert_segment_object();
assert_eq!(segment.trace_id.len() != 0, true);
assert_eq!(segment.trace_segment_id.len() != 0, true);
assert_ne!(segment.trace_id.len(), 0);
assert_ne!(segment.trace_segment_id.len(), 0);
assert_eq!(segment.service, "service");
assert_eq!(segment.service_instance, "instance");
assert_eq!(segment.is_size_limited, false);
assert!(!segment.is_size_limited);
}

#[test]
Expand All @@ -170,11 +166,11 @@ fn create_span_from_context() {
);

let segment = context.convert_segment_object();
assert_eq!(segment.trace_id.len() != 0, true);
assert_eq!(segment.trace_segment_id.len() != 0, true);
assert_ne!(segment.trace_id.len(), 0);
assert_ne!(segment.trace_segment_id.len(), 0);
assert_eq!(segment.service, "service2");
assert_eq!(segment.service_instance, "instance2");
assert_eq!(segment.is_size_limited, false);
assert!(!segment.is_size_limited);
}

#[test]
Expand Down