Skip to content

Commit

Permalink
Remove unused crates from the project (#4179)
Browse files Browse the repository at this point in the history
Remove some unused crates and convert our redis tests to use the `fred`
crate. That means we can remove our dev dependency on the `redis` crate.

This yielded a 1.5% reduction in test build time on my laptop.

<!-- start metadata -->
---

**Checklist**

Complete the checklist (and note appropriate exceptions) before the PR
is marked ready-for-review.

- [ ] Changes are compatible[^1]
- [ ] Documentation[^2] completed
- [ ] Performance impact assessed and acceptable
- Tests added and passing[^3]
    - [ ] Unit Tests
    - [ ] Integration Tests
    - [ ] Manual Tests

**Exceptions**

*Note any exceptions here*

**Notes**

[^1]: It may be appropriate to bring upcoming changes to the attention
of other (impacted) groups. Please endeavour to do this before seeking
PR approval. The mechanism for doing this will vary considerably, so use
your judgement as to how and when to do this.
[^2]: Configuration is an important part of many changes. Where
applicable please try to document configuration examples.
[^3]: Tick whichever testing boxes are applicable. If you are adding
Manual Tests, please document the manual testing (extensively) in the
Exceptions.
  • Loading branch information
garypen authored Nov 10, 2023
1 parent bcaf2ad commit 40759b9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 112 deletions.
90 changes: 7 additions & 83 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ dependencies = [
"proteus",
"rand 0.8.5",
"rand_core 0.6.4",
"redis",
"regex",
"reqwest",
"rhai",
Expand All @@ -388,10 +387,9 @@ dependencies = [
"serde_json_bytes",
"serde_urlencoded",
"serde_yaml",
"sha1 0.10.6",
"sha1",
"sha2",
"shellexpand",
"similar-asserts",
"static_assertions",
"strum_macros",
"sys-info",
Expand Down Expand Up @@ -1137,7 +1135,7 @@ dependencies = [
"serde_json",
"serde_path_to_error",
"serde_urlencoded",
"sha1 0.10.6",
"sha1",
"sync_wrapper",
"tokio",
"tokio-tungstenite",
Expand Down Expand Up @@ -1314,17 +1312,6 @@ dependencies = [
"alloc-stdlib",
]

[[package]]
name = "bstr"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [
"lazy_static",
"memchr",
"regex-automata 0.1.10",
]

[[package]]
name = "bstr"
version = "1.6.0"
Expand Down Expand Up @@ -1582,20 +1569,6 @@ dependencies = [
"unreachable",
]

[[package]]
name = "combine"
version = "4.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
dependencies = [
"bytes",
"futures-core",
"memchr",
"pin-project-lite",
"tokio",
"tokio-util",
]

[[package]]
name = "concolor"
version = "0.1.1"
Expand Down Expand Up @@ -2140,7 +2113,7 @@ dependencies = [
"sec1",
"serde",
"serde_bytes",
"sha1 0.10.6",
"sha1",
"sha2",
"signature 1.6.4",
"spki",
Expand Down Expand Up @@ -3006,7 +2979,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d"
dependencies = [
"aho-corasick",
"bstr 1.6.0",
"bstr",
"fnv",
"log",
"regex",
Expand Down Expand Up @@ -3039,7 +3012,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2ebc8013b4426d5b81a4364c419a95ed0b404af2b82e2457de52d9348f0e474"
dependencies = [
"combine 3.8.1",
"combine",
"thiserror",
]

Expand Down Expand Up @@ -3174,7 +3147,7 @@ dependencies = [
"http",
"httpdate",
"mime",
"sha1 0.10.6",
"sha1",
]

[[package]]
Expand Down Expand Up @@ -5240,26 +5213,6 @@ dependencies = [
"num_cpus",
]

[[package]]
name = "redis"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "152f3863635cbb76b73bc247845781098302c6c9ad2060e1a9a7de56840346b6"
dependencies = [
"async-trait",
"bytes",
"combine 4.6.6",
"futures-util",
"itoa",
"percent-encoding",
"pin-project-lite",
"ryu",
"sha1 0.6.1",
"tokio",
"tokio-util",
"url",
]

[[package]]
name = "redis-protocol"
version = "4.1.0"
Expand Down Expand Up @@ -6065,15 +6018,6 @@ dependencies = [
"digest 0.10.7",
]

[[package]]
name = "sha1"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770"
dependencies = [
"sha1_smol",
]

[[package]]
name = "sha1"
version = "0.10.6"
Expand All @@ -6085,12 +6029,6 @@ dependencies = [
"digest 0.10.7",
]

[[package]]
name = "sha1_smol"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"

[[package]]
name = "sha2"
version = "0.10.8"
Expand Down Expand Up @@ -6160,20 +6098,6 @@ name = "similar"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf"
dependencies = [
"bstr 0.2.17",
"unicode-segmentation",
]

[[package]]
name = "similar-asserts"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e041bb827d1bfca18f213411d51b665309f1afb37a04a5d1464530e13779fc0f"
dependencies = [
"console 0.15.7",
"similar",
]

[[package]]
name = "simple_asn1"
Expand Down Expand Up @@ -7204,7 +7128,7 @@ dependencies = [
"log",
"rand 0.8.5",
"rustls",
"sha1 0.10.6",
"sha1",
"thiserror",
"url",
"utf-8",
Expand Down
3 changes: 0 additions & 3 deletions apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ prost = "0.11.9"
prost-types = "0.11.9"
proteus = "0.5.0"
rand = "0.8.5"
rand_core = "0.6.4"
rhai = { version = "1.16.2", features = ["sync", "serde", "internals"] }
regex = "1.10.2"
reqwest = { version = "0.11.22", default-features = false, features = [
Expand Down Expand Up @@ -283,7 +282,6 @@ once_cell = "1.18.0"
opentelemetry-stdout = { version = "0.1.0", features = ["trace"] }
p256 = "0.12.0"
rand_core = "0.6.4"
redis = { version = "0.21.7", features = ["tokio-comp"] }
reqwest = { version = "0.11.22", default-features = false, features = [
"json",
"stream",
Expand All @@ -294,7 +292,6 @@ rhai = { version = "1.16.2", features = [
"internals",
"testing-environ",
] }
similar-asserts = "1.5.0"
tempfile = "3.8.0"
test-log = { version = "0.2.13", default-features = false, features = [
"trace",
Expand Down
1 change: 1 addition & 0 deletions apollo-router/src/http_server_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl HttpServerHandle {
}

pub(crate) async fn shutdown(mut self) -> Result<(), ApolloRouterError> {
#[cfg(unix)]
let listen_addresses = std::mem::take(&mut self.listen_addresses);

let (_main_listener, _extra_listener) = self.wait_for_servers().await?;
Expand Down
47 changes: 21 additions & 26 deletions apollo-router/tests/redis_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ mod test {
use apollo_router::services::execution::QueryPlan;
use apollo_router::services::router;
use apollo_router::services::supergraph;
use fred::prelude::*;
use futures::StreamExt;
use http::Method;
use redis::AsyncCommands;
use redis::Client;
use serde::Deserialize;
use serde::Serialize;
use serde_json::json;
Expand All @@ -15,14 +14,12 @@ mod test {

#[tokio::test(flavor = "multi_thread")]
async fn query_planner() -> Result<(), BoxError> {
let client = Client::open("redis://127.0.0.1:6379").expect("opening ClusterClient");
let mut connection = client
.get_async_connection()
.await
.expect("got redis connection");
let config = RedisConfig::from_url("redis://127.0.0.1:6379")?;
let client = RedisClient::new(config, None, None);
let connection_task = client.connect();
client.wait_for_connect().await?;

connection
.del::<&'static str, ()>("plan.5abb5fecf7df056396fb90fdf38d430b8c1fec55ec132fde878161608af18b76.4c45433039407593557f8a982dafd316a66ec03f0e1ed5fa1b7ef8060d76e8ec.3973e022e93220f9212c18d0d0c543ae7c309e46640da93a4a0314de999f5112.4f918cb09d5956bea87fe8addb4db3bd16de2cdf935e899cf252cac5528090e4").await.unwrap();
client.del::<String, _>("plan.5abb5fecf7df056396fb90fdf38d430b8c1fec55ec132fde878161608af18b76.4c45433039407593557f8a982dafd316a66ec03f0e1ed5fa1b7ef8060d76e8ec.3973e022e93220f9212c18d0d0c543ae7c309e46640da93a4a0314de999f5112.4f918cb09d5956bea87fe8addb4db3bd16de2cdf935e899cf252cac5528090e4").await.unwrap();

let supergraph = apollo_router::TestHarness::builder()
.with_subgraph_network_requests()
Expand Down Expand Up @@ -51,7 +48,7 @@ mod test {

let _ = supergraph.oneshot(request).await?.next_response().await;

let s:String = connection
let s:String = client
.get("plan.5abb5fecf7df056396fb90fdf38d430b8c1fec55ec132fde878161608af18b76.4c45433039407593557f8a982dafd316a66ec03f0e1ed5fa1b7ef8060d76e8ec.3973e022e93220f9212c18d0d0c543ae7c309e46640da93a4a0314de999f5112.4f918cb09d5956bea87fe8addb4db3bd16de2cdf935e899cf252cac5528090e4")
.await
.unwrap();
Expand All @@ -69,7 +66,9 @@ mod test {
.get("root");

insta::assert_json_snapshot!(query_plan);

client.quit().await?;
// calling quit ends the connection and event listener tasks
let _ = connection_task.await;
Ok(())
}

Expand All @@ -81,11 +80,10 @@ mod test {

#[tokio::test(flavor = "multi_thread")]
async fn apq() -> Result<(), BoxError> {
let client = Client::open("redis://127.0.0.1:6379").expect("opening ClusterClient");
let mut connection = client
.get_async_connection()
.await
.expect("got redis connection");
let config = RedisConfig::from_url("redis://127.0.0.1:6379")?;
let client = RedisClient::new(config, None, None);
let connection_task = client.connect();
client.wait_for_connect().await?;

let config = json!({
"apq": {
Expand All @@ -111,8 +109,8 @@ mod test {

let query_hash = "4c45433039407593557f8a982dafd316a66ec03f0e1ed5fa1b7ef8060d76e8ec";

connection
.del::<String, ()>(format!("apq\x00{query_hash}"))
client
.del::<String, _>(&format!("apq\x00{query_hash}"))
.await
.unwrap();

Expand Down Expand Up @@ -141,10 +139,7 @@ mod test {
.unwrap()?;
assert_eq!(res.errors.get(0).unwrap().message, "PersistedQueryNotFound");

let r: Option<String> = connection
.get(&format!("apq\x00{query_hash}"))
.await
.unwrap();
let r: Option<String> = client.get(&format!("apq\x00{query_hash}")).await.unwrap();
assert!(r.is_none());

// Now we register the query
Expand All @@ -169,10 +164,7 @@ mod test {
assert!(res.data.is_some());
assert!(res.errors.is_empty());

let s: Option<String> = connection
.get(&format!("apq\x00{query_hash}"))
.await
.unwrap();
let s: Option<String> = client.get(&format!("apq\x00{query_hash}")).await.unwrap();
insta::assert_display_snapshot!(s.unwrap());

// we start a new router with the same config
Expand Down Expand Up @@ -204,6 +196,9 @@ mod test {
assert!(res.data.is_some());
assert!(res.errors.is_empty());

client.quit().await?;
// calling quit ends the connection and event listener tasks
let _ = connection_task.await;
Ok(())
}
}

0 comments on commit 40759b9

Please sign in to comment.