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

Improve GHA testing. #166

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
95 changes: 30 additions & 65 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
- master
schedule:
- cron: '0 3 * * 0' # Every sunday at 3am UTC.
env:
CARGO_TERM_COLOR: always

jobs:
build:
Expand All @@ -15,97 +17,60 @@ jobs:
matrix:
os: [ubuntu-latest, windows-2019, macos-11]
rust: [stable, beta, nightly]
exclude:
- os: windows-2019
rust: beta

- os: windows-2019
rust: nightly

- os: macos-11
rust: beta

- os: macos-11
rust: nightly


runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install
run: |
rustup update
rustup default ${{ matrix.rust }}

- name: Build
run: cargo check --all-targets
continue-on-error: ${{ matrix.rust == 'nightly' }}

tests_single_node:
name: Tests Single node configuration
needs: build
strategy:
matrix:
version: [ previous-lts, lts, ci ]
secure: [ true, false ]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install
run: rustup update stable

- name: Generate certificates
if: ${{ matrix.secure == true }}
run: |
docker-compose --file configure-tls-for-tests.yml up

- name: Test on single-node EventStoreDB ${{ matrix.version }}
run: cargo test --package eventstore --test integration single_node
env:
CONTAINER_IMAGE_VERSION: ${{ matrix.version }}
RUST_LOG: integration=debug,eventstore=debug
RUST_BACKTRACE: 1
SECURE: ${{ matrix.secure }}
- name: Unit tests
run: cargo test --lib

tests_cluster:
name: Tests Cluster configuration.
tests:
needs: build
name: Tests

strategy:
fail-fast: false
matrix:
version: [ previous-lts, lts, latest ]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install
run: rustup update stable
- name: Set up EventStoreDB ${{ matrix.version }} cluster with Docker Compose
run: docker-compose up -d

- name: Test on three-cluster-node EventStoreDB ${{ matrix.version }}
run: |
cargo test --package eventstore --test integration -- cluster
docker-compose down
env:
CONTAINER_IMAGE_VERSION: ${{ matrix.version }}
RUST_LOG: integration=debug,eventstore=debug
RUST_BACKTRACE: 1
version: [previous-lts, lts, latest, ci]

tests_library:
name: Tests library unit tests
needs: build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install
run: rustup update stable
- name: Run library unit tests
run: cargo test --lib
uses: ./.github/workflows/tests.yml
with:
esdb_version: ${{ matrix.version }}

linting:
name: Linting
needs:
- tests_single_node
- tests_library
- tests_cluster
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install
run: |
rustup update stable
rustup component add clippy-preview
rustup component add clippy
rustup component add rustfmt
- name: Linting
run: cargo clippy --all-features -- -D warnings
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/test-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Dispatch"

on:
workflow_dispatch:
inputs:
version:
description: "Version tag"
required: true
type: string

jobs:
test:
name: Test
uses: ./.github/workflows/tests.yml
with:
esdb_version: ${{ inputs.version }}
103 changes: 103 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: tests workflow

on:
workflow_call:
inputs:
esdb_version:
required: true
type: string

env:
CARGO_TERM_COLOR: always

jobs:
single_node:
name: Single node

strategy:
fail-fast: false
matrix:
test: [streams, projections, persistent_subscriptions, discover_error, auto_resub_on_connection_drop]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install
run: rustup update stable

- name: Run test
run: cargo test --package eventstore --test integration single_node_${{ matrix.test }}
continue-on-error: ${{ matrix.test == 'auto_resub_on_connection_drop' }}
env:
CONTAINER_IMAGE_VERSION: ${{ inputs.esdb_version }}
RUST_LOG: integration=debug,eventstore=debug
RUST_BACKTRACE: 1

- uses: actions/upload-artifact@v3
if: failure() && matrix.test != 'auto_resub_on_connection_drop'
with:
name: esdb-logs
path: eventstore/esdb_logs

secure:
name: Secure

strategy:
fail-fast: false
matrix:
test: [operations]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install
run: rustup update stable

- name: Generate certificates
run: docker-compose --file configure-tls-for-tests.yml up

- name: Run test
run: cargo test --package eventstore --test integration single_node_${{ matrix.test }}
env:
CONTAINER_IMAGE_VERSION: ${{ inputs.esdb_version }}
RUST_LOG: integration=debug,eventstore=debug
RUST_BACKTRACE: 1
SECURE: true

- uses: actions/upload-artifact@v3
if: failure()
with:
name: esdb-logs
path: eventstore/esdb_logs

cluster:
name: Cluster

strategy:
fail-fast: false
matrix:
test: [streams, projections, persistent_subscriptions]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install
run: rustup update stable

- name: Set up cluster with Docker Compose
run: docker-compose up -d
env:
CONTAINER_IMAGE_VERSION: ${{ inputs.esdb_version }}

- name: Run test
run: cargo test --package eventstore --test integration cluster_${{ matrix.test }}
env:
CONTAINER_IMAGE_VERSION: ${{ inputs.esdb_version }}
RUST_LOG: integration=debug,eventstore=debug
RUST_BACKTRACE: 1

- name: Shutdown cluster
run: docker-compose down
5 changes: 3 additions & 2 deletions eventstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ name = "integration"

[dev-dependencies]
names = "0.14"
pretty_env_logger = "0.4"
pretty_env_logger = "0.5"
serde = { version = "1", features = ["derive"] }
testcontainers = "0.14"
tokio = { version = "1.20", default-features = false, features = [
"rt-multi-thread",
"macros",
] }
toml = "0.5"
toml = "0.7"
eyre = "0.6"

[package.metadata.docs.rs]
all-features = true
Expand Down
7 changes: 7 additions & 0 deletions eventstore/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,8 @@ impl Subscription {
if e.is_access_denied() || !self.retry_enabled {
return Err(e);
}

debug!("Initiate re-subscription");
}

Ok(resp) => {
Expand Down Expand Up @@ -1279,7 +1281,10 @@ impl Subscription {
}
}
} else {
debug!("Subscribing...");
debug!("Before waiting for the current selected node");
let handle = self.connection.current_selected_node().await?;
debug!("Received selected node");

self.channel_id = handle.id();

Expand All @@ -1290,8 +1295,10 @@ impl Subscription {

*req.metadata_mut() = self.metadata.clone();

debug!("Before calling the subscription endpoint...");
match client.read(req).await {
Err(status) => {
debug!("Error when calling the subscription endpoint: {}", status);
let e = crate::Error::from_grpc(status);

handle_error(&self.connection.sender, self.channel_id, &e);
Expand Down
Loading
Loading