From 1240d599494b6089fc2e45ab428baeeb952b68fc Mon Sep 17 00:00:00 2001 From: tison Date: Thu, 13 Jan 2022 14:22:58 +0800 Subject: [PATCH] enable e2e test Signed-off-by: tison --- .github/workflows/{test.yaml => codecov.yaml} | 2 +- .github/workflows/e2e.yml | 25 +++++++++++++++++++ docker-compose.e2e.yml | 4 +-- src/reporter/grpc.rs | 1 + tests/e2e/Cargo.lock | 4 ++- tests/e2e/Cargo.toml | 6 ++--- tests/e2e/docker/Dockerfile | 6 ++--- tests/e2e/docker/Dockerfile.tool | 15 ----------- tests/e2e/src/main.rs | 6 +++-- 9 files changed, 39 insertions(+), 30 deletions(-) rename .github/workflows/{test.yaml => codecov.yaml} (96%) create mode 100644 .github/workflows/e2e.yml delete mode 100644 tests/e2e/docker/Dockerfile.tool diff --git a/.github/workflows/test.yaml b/.github/workflows/codecov.yaml similarity index 96% rename from .github/workflows/test.yaml rename to .github/workflows/codecov.yaml index 91b5a22..2a8a124 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/codecov.yaml @@ -1,4 +1,4 @@ -name: test +name: codecov on: pull_request: push: diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..a581102 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,25 @@ +name: agent-test-tool + +on: + pull_request: + push: + branches: + - master + tags: + - 'v*' + +jobs: + e2e-rust: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Prepare service container + run: docker-compose -f docker-compose.e2e.yml up --build -d + - name: Run e2e + run: | + 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 diff --git a/docker-compose.e2e.yml b/docker-compose.e2e.yml index 3c28ead..e5fd43d 100644 --- a/docker-compose.e2e.yml +++ b/docker-compose.e2e.yml @@ -1,9 +1,7 @@ version: "3.7" services: collector: - build: - context: . - dockerfile: ./tests/e2e/docker/Dockerfile.tool + image: ghcr.io/apache/skywalking-agent-test-tool/mock-collector:5acb890f225ca37ee60675ce3e330545e23e3cbc ports: - 19876:19876 - 12800:12800 diff --git a/src/reporter/grpc.rs b/src/reporter/grpc.rs index 38399c1..4b0c690 100644 --- a/src/reporter/grpc.rs +++ b/src/reporter/grpc.rs @@ -58,6 +58,7 @@ impl Reporter { /// let mut context = TracingContext::default("service", "instance"); /// reporter.sender().send(context).await?; /// reporter.shutdown().await?; + /// Ok(()) /// } /// ``` pub async fn start(address: impl Into) -> Self { diff --git a/tests/e2e/Cargo.lock b/tests/e2e/Cargo.lock index 197c8a4..baccba5 100644 --- a/tests/e2e/Cargo.lock +++ b/tests/e2e/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "ansi_term" version = "0.12.1" @@ -671,7 +673,7 @@ dependencies = [ [[package]] name = "skywalking_rust" -version = "0.0.1" +version = "0.1.0" dependencies = [ "async-stream", "base64", diff --git a/tests/e2e/Cargo.toml b/tests/e2e/Cargo.toml index 6a5cf5b..0e3c003 100644 --- a/tests/e2e/Cargo.toml +++ b/tests/e2e/Cargo.toml @@ -2,12 +2,10 @@ name = "e2e" version = "0.1.0" authors = ["Shikugawa "] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +edition = "2021" [dependencies] -skywalking_rust = { path = "../../" } +skywalking_rust = { path = "../.." } hyper = { version = "0.14", features = ["full"] } tokio = { version = "1", features = ["full"] } structopt = "0.3" diff --git a/tests/e2e/docker/Dockerfile b/tests/e2e/docker/Dockerfile index 2ec7258..7344592 100644 --- a/tests/e2e/docker/Dockerfile +++ b/tests/e2e/docker/Dockerfile @@ -1,5 +1,3 @@ -FROM rust:1.50.0 -RUN apt update && apt install -y protobuf-compiler -RUN rustup component add rustfmt +FROM rust:1.57.0 COPY . /tmp -WORKDIR tmp/tests/e2e +WORKDIR /tmp/tests/e2e diff --git a/tests/e2e/docker/Dockerfile.tool b/tests/e2e/docker/Dockerfile.tool deleted file mode 100644 index 74ef01c..0000000 --- a/tests/e2e/docker/Dockerfile.tool +++ /dev/null @@ -1,15 +0,0 @@ -FROM openjdk:8 -WORKDIR /tests -ARG COMMIT_HASH=8db606f3470cce75c1b013ae498ac93b862b75b7 -ADD https://github.com/apache/skywalking-agent-test-tool/archive/${COMMIT_HASH}.tar.gz . -RUN tar -xf ${COMMIT_HASH}.tar.gz --strip 1 -RUN rm ${COMMIT_HASH}.tar.gz -RUN ./mvnw -B -DskipTests package - -FROM openjdk:8 -EXPOSE 19876 12800 -WORKDIR /tests -COPY --from=0 /tests/dist/skywalking-mock-collector.tar.gz /tests -RUN tar -xf skywalking-mock-collector.tar.gz --strip 1 -RUN chmod +x bin/collector-startup.sh -ENTRYPOINT bin/collector-startup.sh diff --git a/tests/e2e/src/main.rs b/tests/e2e/src/main.rs index b44de3d..d7a109b 100644 --- a/tests/e2e/src/main.rs +++ b/tests/e2e/src/main.rs @@ -7,6 +7,7 @@ use skywalking_rust::context::propagation::encoder::encode_propagation; use skywalking_rust::context::trace_context::TracingContext; use skywalking_rust::reporter::grpc::Reporter; use std::convert::Infallible; +use std::error::Error; use std::net::SocketAddr; use structopt::StructOpt; use tokio::sync::mpsc; @@ -123,7 +124,7 @@ struct Opt { } #[tokio::main] -async fn main() { +async fn main() -> Result<(), Box> { let opt = Opt::from_args(); let reporter = Reporter::start("http://collector:19876").await; let tx = reporter.sender(); @@ -134,5 +135,6 @@ async fn main() { run_producer_service([0, 0, 0, 0], tx).await; } - reporter.shutdown().await.unwarp(); + reporter.shutdown().await?; + Ok(()) }