Skip to content

Commit

Permalink
remove integration test auth (#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus authored Oct 21, 2024
1 parent a81f28e commit 24f1ac2
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 580 deletions.
18 changes: 0 additions & 18 deletions .env

This file was deleted.

68 changes: 19 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
push:
branches:
- 'main'
- "main"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -12,11 +12,25 @@ concurrency:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
RUSTFLAGS: '-C link-arg=-fuse-ld=lld -D warnings'
RUSTFLAGS: "-C link-arg=-fuse-ld=lld -D warnings"

jobs:
check_formatting:
name: "check formatting"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
components: rustfmt

- run: cargo +nightly fmt --all -- --check

check_and_test:
name: 'check and test'
name: "check and test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
Expand All @@ -36,49 +50,5 @@ jobs:
- run: cargo check
- run: cargo clippy -- -Dwarnings --force-warn deprecated --force-warn dead-code

## Tests
# Install sops (needed for decrypting tests .env file)
- name: Setup sops
uses: nhedger/setup-sops@358bac533e4e92f9ce9f9da563d6265929c88cda # v2

# Install age (needed for decrypting tests .env file)
- name: Setup age
uses: alessiodionisi/setup-age-action@82b9aea163ade7fe23441552a514cf666b214077 # v1.3.0

- name: Unit tests
uses: LNSD/sops-exec-action@6da1fbca63459d9796097496d5f5e6233555b31a # v1
env:
SOPS_AGE_KEY: ${{ secrets.IT_TESTS_AGE_KEY }}
with:
env_file: .env
run: cargo test 'tests::' -- --skip 'tests::it_'

- name: Integration tests (in-tree)
uses: LNSD/sops-exec-action@6da1fbca63459d9796097496d5f5e6233555b31a # v1
env:
SOPS_AGE_KEY: ${{ secrets.IT_TESTS_AGE_KEY }}
with:
env_file: .env
run: cargo test 'tests::it_'

- name: Integration tests (public api)
uses: LNSD/sops-exec-action@6da1fbca63459d9796097496d5f5e6233555b31a # v1
env:
SOPS_AGE_KEY: ${{ secrets.IT_TESTS_AGE_KEY }}
with:
env_file: .env
run: cargo test --test '*'

check_formatting:
name: 'check formatting'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
components: rustfmt

- run: cargo +nightly fmt --all -- --check
- name: unit tests
run: cargo test
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,3 @@ log levels:

Prometheus metrics are served at `:${METRICS_PORT}/metrics`.
The available metrics are defined in [metrics.rs](src/metrics.rs).

## Contributing

The gateway is an open-source project and we welcome contributions. Please see
our [contributing guide](docs/contributing.md) for more information.
132 changes: 0 additions & 132 deletions docs/contributing.md

This file was deleted.

54 changes: 0 additions & 54 deletions src/network/indexer_indexing_poi_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,57 +207,3 @@ async fn send_requests(
// Merge the responses into a single map
responses.into_iter().flatten().collect()
}

#[cfg(test)]
mod tests {
use super::{send_requests, POIS_PER_REQUEST_BATCH_SIZE};

mod it_public_pois_resolution {
use std::time::Duration;

use thegraph_core::{deployment_id, BlockNumber};

use super::*;
use crate::indexers;

/// Test helper to get the testnet indexer url from the environment.
fn test_indexer_url() -> reqwest::Url {
std::env::var("IT_TEST_UPGRADE_INDEXER_URL")
.expect("Missing IT_TEST_UPGRADE_INDEXER_URL")
.parse()
.expect("Invalid IT_TEST_UPGRADE_INDEXER_URL")
}

#[test_with::env(IT_TEST_UPGRADE_INDEXER_URL)]
#[tokio::test]
async fn send_batched_queries_and_merge_results() {
//* Given
let client = reqwest::Client::new();
let status_url = indexers::status_url(test_indexer_url());

let deployment = deployment_id!("QmeYTH2fK2wv96XvnCGH2eyKFE8kmRfo53zYVy5dKysZtH");
let pois_to_query = (1..=POIS_PER_REQUEST_BATCH_SIZE + 2)
.map(|i| (deployment, i as BlockNumber))
.collect::<Vec<_>>();

//* When
let response = tokio::time::timeout(
Duration::from_secs(60),
send_requests(
&client,
status_url,
&pois_to_query,
POIS_PER_REQUEST_BATCH_SIZE,
),
)
.await
.expect("request timed out");

//* Then
assert_eq!(response.len(), POIS_PER_REQUEST_BATCH_SIZE + 2);
assert!(response.contains_key(&(deployment, 1)));
assert!(response.contains_key(&(deployment, 2)));
assert!(response.contains_key(&(deployment, 3)));
}
}
}
86 changes: 0 additions & 86 deletions src/network/indexer_indexing_progress_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,89 +178,3 @@ async fn send_requests(
// Merge the responses into a single map
responses.into_iter().flatten().collect()
}

#[cfg(test)]
mod tests {
use super::{send_requests, INDEXINGS_PER_REQUEST_BATCH_SIZE};

mod it_indexing_progress_resolution {
use std::time::Duration;

use assert_matches::assert_matches;
use thegraph_core::deployment_id;

use super::*;
use crate::indexers;

/// Test helper to get the testnet indexer url from the environment.
fn test_indexer_url() -> reqwest::Url {
std::env::var("IT_TEST_UPGRADE_INDEXER_URL")
.expect("Missing IT_TEST_UPGRADE_INDEXER_URL")
.parse()
.expect("Invalid IT_TEST_UPGRADE_INDEXER_URL")
}

#[test_with::env(IT_TEST_UPGRADE_INDEXER_URL)]
#[tokio::test]
async fn send_batched_queries_and_merge_results() {
//* Given
let client = reqwest::Client::new();
let status_url = indexers::status_url(test_indexer_url());

let test_deployments = [
deployment_id!("QmSWxvd8SaQK6qZKJ7xtfxCCGoRzGnoi2WNzmJYYJW9BXY"),
deployment_id!("QmUhiH6Z5xo6o3GNzsSvqpGKLmCt6w5WzKQ1yHk6C8AA8S"),
];

//* When
let indexing_statuses = tokio::time::timeout(
Duration::from_secs(60),
send_requests(
&client,
status_url,
&test_deployments,
INDEXINGS_PER_REQUEST_BATCH_SIZE,
),
)
.await
.expect("request timed out");

//* Then
assert_eq!(indexing_statuses.len(), 2);

// Status for the first deployment
let chain_status1 = indexing_statuses
.get(&test_deployments[0])
.expect("missing status for deployment 1")
.as_ref()
.expect("fetch failed");

assert_eq!(chain_status1.len(), 1);
let chain = &chain_status1[0];
assert_eq!(chain.network, "arbitrum-one");
assert_matches!(chain.latest_block, Some(ref block) => {
assert!(block.number > 0);
});
assert_matches!(chain.earliest_block, Some(ref block) => {
assert!(block.number > 0);
});

// Status for the second deployment
let chain_status2 = indexing_statuses
.get(&test_deployments[1])
.expect("missing status for deployment")
.as_ref()
.expect("fetch failed");

assert_eq!(chain_status2.len(), 1);
let chain = &chain_status2[0];
assert_eq!(chain.network, "arbitrum-one");
assert_matches!(chain.latest_block, Some(ref block) => {
assert!(block.number > 0);
});
assert_matches!(chain.earliest_block, Some(ref block) => {
assert!(block.number > 0);
});
}
}
}
Loading

0 comments on commit 24f1ac2

Please sign in to comment.