Skip to content

Commit 83a41c8

Browse files
authored
Eliminate Test Utilities Crate (#1003)
1 parent 882c866 commit 83a41c8

101 files changed

Lines changed: 6739 additions & 6677 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,74 @@
33
CLI_VERSION_OVERRIDE = "v1.4.1-cloud-v1-29-0-139-2.0"
44

55
[alias]
6-
integ-test = ["test", "--features", "temporal-sdk-core-protos/serde_serialize", "--package", "temporal-sdk-core", "--test", "integ_runner", "--"]
7-
lint = ["clippy", "--workspace", "--examples", "--all-features",
8-
"--test", "integ_tests", "--test", "heavy_tests", "--test", "manual_tests",
9-
"--", "--D", "warnings"]
10-
lint-fix = ["clippy", "--workspace", "--examples", "--all-features",
11-
"--test", "integ_tests", "--test", "heavy_tests", "--test", "manual_tests",
12-
"--fix", "--allow-dirty"]
13-
test-lint = ["clippy", "--all", "--all-features", "--examples", "--workspace",
14-
"--tests", "--", "--D", "warnings"]
15-
test-lint-fix = ["clippy", "--all", "--all-features", "--examples", "--workspace",
16-
"--tests", "--fix", "--allow-dirty"]
6+
# Not sure why --all-features doesn't work
7+
integ-test = [
8+
"test",
9+
"--features",
10+
"temporal-sdk-core-protos/serde_serialize",
11+
"--features",
12+
"test-utilities",
13+
"--features",
14+
"ephemeral-server",
15+
"--package",
16+
"temporal-sdk-core",
17+
"--test",
18+
"integ_runner",
19+
"--",
20+
]
21+
lint = [
22+
"clippy",
23+
"--workspace",
24+
"--examples",
25+
"--all-features",
26+
"--test",
27+
"integ_tests",
28+
"--test",
29+
"heavy_tests",
30+
"--test",
31+
"manual_tests",
32+
"--test",
33+
"cloud_tests",
34+
"--test",
35+
"integ_runner",
36+
"--test",
37+
"global_metric_tests",
38+
"--",
39+
"--D",
40+
"warnings",
41+
]
42+
lint-fix = [
43+
"clippy",
44+
"--workspace",
45+
"--examples",
46+
"--all-features",
47+
"--test",
48+
"integ_tests",
49+
"--test",
50+
"heavy_tests",
51+
"--test",
52+
"manual_tests",
53+
"--fix",
54+
"--allow-dirty",
55+
]
56+
test-lint = [
57+
"clippy",
58+
"--all",
59+
"--all-features",
60+
"--examples",
61+
"--workspace",
62+
"--tests",
63+
"--",
64+
"--D",
65+
"warnings",
66+
]
67+
test-lint-fix = [
68+
"clippy",
69+
"--all",
70+
"--all-features",
71+
"--examples",
72+
"--workspace",
73+
"--tests",
74+
"--fix",
75+
"--allow-dirty",
76+
]

.github/workflows/per-pr.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: arduino/setup-protoc@v3
2727
with:
2828
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
29-
version: '23.x'
29+
version: "23.x"
3030
repo-token: ${{ secrets.GITHUB_TOKEN }}
3131
- run: rustup component add rustfmt clippy
3232
- uses: Swatinem/rust-cache@v2
@@ -43,7 +43,7 @@ jobs:
4343
strategy:
4444
fail-fast: false
4545
matrix:
46-
os: [ ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest ]
46+
os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
4747
include:
4848
- os: windows-latest
4949
- os: ubuntu-latest
@@ -63,7 +63,7 @@ jobs:
6363
uses: arduino/setup-protoc@v3
6464
with:
6565
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
66-
version: '23.x'
66+
version: "23.x"
6767
repo-token: ${{ secrets.GITHUB_TOKEN }}
6868
# Workaround for https://github.com/actions/runner-images/issues/12432
6969
# from https://github.com/rust-lang/rust/issues/141626#issuecomment-2919419236
@@ -91,7 +91,7 @@ jobs:
9191
strategy:
9292
fail-fast: false
9393
matrix:
94-
os: [ ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest ]
94+
os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
9595
include:
9696
- os: windows-latest
9797
- os: ubuntu-latest
@@ -111,9 +111,17 @@ jobs:
111111
uses: arduino/setup-protoc@v3
112112
with:
113113
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
114-
version: '23.x'
114+
version: "23.x"
115115
repo-token: ${{ secrets.GITHUB_TOKEN }}
116-
116+
# Workaround for https://github.com/actions/runner-images/issues/12432
117+
# from https://github.com/rust-lang/rust/issues/141626#issuecomment-2919419236
118+
# Visual Studio bug tracker https://developercommunity.visualstudio.com/t/Regression-from-1943:-linkexe-crashes/10912960
119+
- name: Setup RUSTFLAGS (Windows)
120+
if: runner.os == 'Windows'
121+
uses: actions/github-script@v7
122+
with:
123+
script: |
124+
core.exportVariable('RUSTFLAGS', '-Csymbol-mangling-version=v0');
117125
- uses: Swatinem/rust-cache@v2
118126
- run: cargo integ-test
119127

@@ -136,11 +144,11 @@ jobs:
136144
uses: arduino/setup-protoc@v3
137145
with:
138146
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
139-
version: '23.x'
147+
version: "23.x"
140148
repo-token: ${{ secrets.GITHUB_TOKEN }}
141149

142150
- uses: Swatinem/rust-cache@v2
143-
- run: cargo test --test cloud_tests
151+
- run: cargo test --features=test-utilities --test cloud_tests
144152

145153
docker-integ-tests:
146154
name: Docker integ tests
@@ -161,7 +169,7 @@ jobs:
161169
uses: arduino/setup-protoc@v3
162170
with:
163171
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
164-
version: '23.x'
172+
version: "23.x"
165173
repo-token: ${{ secrets.GITHUB_TOKEN }}
166174
- name: Start container for otel-collector and prometheus
167175
uses: hoverkraft-tech/compose-action@v2.0.1

Cargo.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
[workspace]
2-
members = ["core", "client", "core-api", "fsm", "test-utils", "sdk-core-protos", "sdk", "core-c-bridge"]
2+
members = [
3+
"core",
4+
"client",
5+
"core-api",
6+
"fsm",
7+
"sdk-core-protos",
8+
"sdk",
9+
"core-c-bridge",
10+
]
311
resolver = "2"
412

513
[workspace.package]
@@ -8,7 +16,14 @@ license-file = "LICENSE.txt"
816

917
[workspace.dependencies]
1018
derive_builder = "0.20"
11-
derive_more = { version = "2.0", features = ["constructor", "display", "from", "into", "debug", "try_into"] }
19+
derive_more = { version = "2.0", features = [
20+
"constructor",
21+
"display",
22+
"from",
23+
"into",
24+
"debug",
25+
"try_into",
26+
] }
1227
thiserror = "2"
1328
tonic = "0.13"
1429
tonic-build = "0.13"

client/src/callback_based.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
44
use anyhow::anyhow;
55
use bytes::{BufMut, BytesMut};
6-
use futures_util::future::BoxFuture;
7-
use futures_util::stream;
6+
use futures_util::{future::BoxFuture, stream};
87
use http::{HeaderMap, Request, Response};
98
use http_body_util::{BodyExt, StreamBody, combinators::BoxBody};
109
use hyper::body::{Bytes, Frame};

client/src/metrics.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::{AttachMetricLabels, CallType, callback_based, dbg_panic};
2-
use futures_util::TryFutureExt;
3-
use futures_util::future::Either;
4-
use futures_util::{FutureExt, future::BoxFuture};
2+
use futures_util::{
3+
FutureExt, TryFutureExt,
4+
future::{BoxFuture, Either},
5+
};
56
use std::{
67
fmt,
78
sync::Arc,

core-c-bridge/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ path = "../sdk-core-protos"
4444
futures-util = "0.3"
4545
thiserror = { workspace = true }
4646

47-
[dev-dependencies.temporal-sdk-core-test-utils]
48-
path = "../test-utils"
4947

5048
[build-dependencies]
5149
cbindgen = { version = "0.29", default-features = false }

core-c-bridge/src/client.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ use crate::{
44

55
use futures_util::FutureExt;
66
use prost::bytes::Bytes;
7-
use std::cell::OnceCell;
8-
use std::str::FromStr;
9-
use std::sync::Arc;
10-
use std::sync::atomic::AtomicBool;
11-
use std::sync::atomic::Ordering;
12-
use std::time::Duration;
7+
use std::{
8+
cell::OnceCell,
9+
str::FromStr,
10+
sync::{
11+
Arc,
12+
atomic::{AtomicBool, Ordering},
13+
},
14+
time::Duration,
15+
};
1316
use temporal_client::{
1417
ClientKeepAliveConfig, ClientOptions as CoreClientOptions, ClientOptionsBuilder,
1518
ClientTlsConfig, CloudService, ConfiguredClient, HealthService, HttpConnectProxyOptions,

core-c-bridge/src/runtime.rs

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
use crate::ByteArray;
2-
use crate::ByteArrayRef;
3-
use crate::MetadataRef;
4-
use crate::metric::CustomMetricMeter;
5-
use crate::metric::CustomMetricMeterRef;
1+
use crate::{
2+
ByteArray, ByteArrayRef, MetadataRef,
3+
metric::{CustomMetricMeter, CustomMetricMeterRef},
4+
};
65

76
use serde_json::json;
8-
use std::collections::HashMap;
9-
use std::fmt;
10-
use std::net::SocketAddr;
11-
use std::str::FromStr;
12-
use std::sync::atomic::AtomicBool;
13-
use std::sync::atomic::Ordering;
14-
use std::sync::{Arc, Mutex};
15-
use std::time::Duration;
16-
use std::time::UNIX_EPOCH;
17-
use temporal_sdk_core::CoreRuntime;
18-
use temporal_sdk_core::TokioRuntimeBuilder;
19-
use temporal_sdk_core::telemetry::{build_otlp_metric_exporter, start_prometheus_metric_exporter};
20-
use temporal_sdk_core_api::telemetry::HistogramBucketOverrides;
21-
use temporal_sdk_core_api::telemetry::MetricTemporality;
22-
use temporal_sdk_core_api::telemetry::metrics::CoreMeter;
23-
use temporal_sdk_core_api::telemetry::{CoreLog, CoreLogConsumer};
7+
use std::{
8+
collections::HashMap,
9+
fmt,
10+
net::SocketAddr,
11+
str::FromStr,
12+
sync::{
13+
Arc, Mutex,
14+
atomic::{AtomicBool, Ordering},
15+
},
16+
time::{Duration, UNIX_EPOCH},
17+
};
18+
use temporal_sdk_core::{
19+
CoreRuntime, TokioRuntimeBuilder,
20+
telemetry::{build_otlp_metric_exporter, start_prometheus_metric_exporter},
21+
};
2422
use temporal_sdk_core_api::telemetry::{
25-
Logger, OtelCollectorOptionsBuilder, PrometheusExporterOptionsBuilder,
26-
TelemetryOptions as CoreTelemetryOptions, TelemetryOptionsBuilder,
23+
CoreLog, CoreLogConsumer, HistogramBucketOverrides, Logger, MetricTemporality,
24+
OtelCollectorOptionsBuilder, PrometheusExporterOptionsBuilder,
25+
TelemetryOptions as CoreTelemetryOptions, TelemetryOptionsBuilder, metrics::CoreMeter,
2726
};
2827
use tracing::Level;
2928
use url::Url;

core-c-bridge/src/testing.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use std::time::Duration;
22

3-
use crate::ByteArray;
4-
use crate::ByteArrayRef;
5-
use crate::UserDataHandle;
6-
use crate::runtime::Runtime;
3+
use crate::{ByteArray, ByteArrayRef, UserDataHandle, runtime::Runtime};
74

85
use temporal_sdk_core::ephemeral_server;
96

core-c-bridge/src/tests/context.rs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
1-
use crate::client::{
2-
Client, ClientHttpConnectProxyOptions, ClientKeepAliveOptions, ClientRetryOptions,
3-
ClientTlsOptions, RpcCallOptions, temporal_core_client_connect, temporal_core_client_free,
4-
temporal_core_client_rpc_call,
5-
};
6-
use crate::runtime::{
7-
Runtime, RuntimeOptions, RuntimeOrFail, temporal_core_byte_array_free,
8-
temporal_core_runtime_free, temporal_core_runtime_new,
9-
};
10-
use crate::testing::{
11-
DevServerOptions, EphemeralServer, TestServerOptions, temporal_core_ephemeral_server_free,
12-
temporal_core_ephemeral_server_shutdown, temporal_core_ephemeral_server_start_dev_server,
1+
use crate::{
2+
client::{
3+
Client, ClientHttpConnectProxyOptions, ClientKeepAliveOptions, ClientRetryOptions,
4+
ClientTlsOptions, RpcCallOptions, temporal_core_client_connect, temporal_core_client_free,
5+
temporal_core_client_rpc_call,
6+
},
7+
runtime::{
8+
Runtime, RuntimeOptions, RuntimeOrFail, temporal_core_byte_array_free,
9+
temporal_core_runtime_free, temporal_core_runtime_new,
10+
},
11+
testing::{
12+
DevServerOptions, EphemeralServer, TestServerOptions, temporal_core_ephemeral_server_free,
13+
temporal_core_ephemeral_server_shutdown, temporal_core_ephemeral_server_start_dev_server,
14+
},
1315
};
1416

15-
use crate::tests::utils::{
16-
MetadataMap, OwnedRpcCallOptions, RpcCallError, byte_array_to_string, byte_array_to_vec,
17-
pointer_or_null,
17+
use crate::{
18+
ByteArray, ByteArrayRef,
19+
tests::utils::{
20+
MetadataMap, OwnedRpcCallOptions, RpcCallError, byte_array_to_string, byte_array_to_vec,
21+
pointer_or_null,
22+
},
1823
};
19-
use crate::{ByteArray, ByteArrayRef};
2024
use anyhow::anyhow;
21-
use std::any::Any;
22-
use std::panic::{AssertUnwindSafe, UnwindSafe};
23-
use std::ptr::NonNull;
24-
use std::sync::{Arc, Condvar, Mutex, MutexGuard, PoisonError, Weak};
25-
use std::time::Duration;
25+
use std::{
26+
any::Any,
27+
panic::{AssertUnwindSafe, UnwindSafe},
28+
ptr::NonNull,
29+
sync::{Arc, Condvar, Mutex, MutexGuard, PoisonError, Weak},
30+
time::Duration,
31+
};
2632
use temporal_client::ClientOptions;
2733
use temporal_sdk_core::ephemeral_server::{
2834
EphemeralExe, EphemeralExeVersion, TemporalDevServerConfig,

0 commit comments

Comments
 (0)