From 2d9438233f6bad3c0e4e438f4c17d0dbd9630a49 Mon Sep 17 00:00:00 2001 From: mxsm Date: Mon, 18 Sep 2023 09:26:54 +0800 Subject: [PATCH] [ISSUE #171]Integration Test with nacos-server (#191) --- .github/workflows/ci.yml | 19 +++++++++++++++++-- examples/simple_app.rs | 6 ++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afd9102..2c9d14a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,6 @@ jobs: lint: name: Lint runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - name: cargo fmt @@ -28,11 +27,27 @@ jobs: - name: cargo clippy run: cargo clippy -- -W warnings + regression-test: + runs-on: ubuntu-latest + steps: + - run: echo "Get latest nacos from docker hub" + - run: docker --version + - run: sudo docker pull nacos/nacos-server:latest + - run: sudo docker run --name nacos-quick -e MODE=standalone -p 8848:8848 -p 9848:9848 -d nacos/nacos-server:latest + - run: sudo apt install -y protobuf-compiler libprotobuf-dev + - name: Check out repository code + uses: actions/checkout@v3 + - run: cargo --version --verbose + - run: rustc --version --verbose + - name: format check + run: cargo fmt --check + - name: unit test + run: cargo test --all-targets + - run: cargo run --example simple_app build: name: Build runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - name: Build diff --git a/examples/simple_app.rs b/examples/simple_app.rs index 9379ee4..12de0aa 100644 --- a/examples/simple_app.rs +++ b/examples/simple_app.rs @@ -7,6 +7,8 @@ use nacos_sdk::api::naming::{ }; use nacos_sdk::api::props::ClientProps; +const NACOS_ADDRESS: &str = "127.0.0.1:8848"; + /// enable https auth run with command: /// cargo run --example simple_app --features default,tls #[tokio::main] @@ -19,7 +21,7 @@ async fn main() -> Result<(), Box> { .init(); let client_props = ClientProps::new() - .server_addr("0.0.0.0:8848") + .server_addr(NACOS_ADDRESS) // .remote_grpc_port(9838) // Attention! "public" is "", it is recommended to customize the namespace with clear meaning. .namespace("") @@ -84,7 +86,7 @@ async fn main() -> Result<(), Box> { Err(err) => tracing::error!("naming get_all_instances error {:?}", err), } - tokio::time::sleep(tokio::time::Duration::from_secs(300)).await; + tokio::time::sleep(tokio::time::Duration::from_millis(300)).await; Ok(()) }