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

Enable integration tests with Daphne Helper #3030

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
37 changes: 14 additions & 23 deletions integration_tests/src/daphne.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use serde_json::json;
use testcontainers::{clients::Cli, GenericImage, RunnableImage};
use url::Url;

const DAPHNE_HELPER_IMAGE_NAME_AND_TAG: &str = "cloudflare/daphne-worker-helper:sha-f6b3ef1";
const DAPHNE_HELPER_IMAGE_NAME_AND_TAG: &str = "cloudflare/daphne-worker-helper:sha-4c612db";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer note: This tag was created manually. It matches the commit that was checked out when the image was built. In the future we will add publishing the container to CI.


/// Represents a running Daphne test instance.
pub struct Daphne<'a> {
daphne_container: Option<ContainerLogsDropGuard<'a, GenericImage>>,
daphne_container: ContainerLogsDropGuard<'a, GenericImage>,
}

impl<'a> Daphne<'a> {
Expand All @@ -28,7 +28,6 @@ impl<'a> Daphne<'a> {
network: &str,
task: &Task,
role: Role,
start_container: bool,
) -> Daphne<'a> {
let (endpoint, image_name_and_tag) = match role {
Role::Leader => panic!("A leader container image for Daphne is not yet available"),
Expand All @@ -43,22 +42,17 @@ impl<'a> Daphne<'a> {
.unwrap_or((image_name_and_tag, "latest"));

// Start the Daphne test container running.
let (port, daphne_container) = if start_container {
let runnable_image = RunnableImage::from(GenericImage::new(image_name, image_tag))
.with_network(network)
// Daphne uses the DAP_TRACING environment variable for its tracing subscriber.
.with_env_var(("DAP_TRACING", get_rust_log_level().1))
.with_container_name(endpoint.host_str().unwrap());
let daphne_container = ContainerLogsDropGuard::new(
test_name,
container_client.run(runnable_image),
ContainerLogsSource::Path("/logs".into()),
);
let port = daphne_container.get_host_port_ipv4(Self::INTERNAL_SERVING_PORT);
(port, Some(daphne_container))
} else {
(Self::INTERNAL_SERVING_PORT, None)
};
let runnable_image = RunnableImage::from(GenericImage::new(image_name, image_tag))
.with_network(network)
// Daphne uses the DAP_TRACING environment variable for its tracing subscriber.
.with_env_var(("DAP_TRACING", get_rust_log_level().1))
.with_container_name(endpoint.host_str().unwrap());
let daphne_container = ContainerLogsDropGuard::new(
test_name,
container_client.run(runnable_image),
ContainerLogsSource::Path("/logs".into()),
);
let port = daphne_container.get_host_port_ipv4(Self::INTERNAL_SERVING_PORT);

// Wait for Daphne container to begin listening on the port.
await_ready_ok(port).await;
Expand Down Expand Up @@ -129,9 +123,6 @@ impl<'a> Daphne<'a> {
/// Returns the port of the aggregator on the host.
pub fn port(&self) -> u16 {
self.daphne_container
.as_ref()
.map_or(Self::INTERNAL_SERVING_PORT, |container| {
container.get_host_port_ipv4(Self::INTERNAL_SERVING_PORT)
})
.get_host_port_ipv4(Self::INTERNAL_SERVING_PORT)
}
}
23 changes: 2 additions & 21 deletions integration_tests/tests/integration/daphne.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,7 @@ async fn daphne_janus() {
.build();

let container_client = container_client();
let leader = Daphne::new(
TEST_NAME,
&container_client,
&network,
&task,
Role::Leader,
true,
)
.await;
let leader = Daphne::new(TEST_NAME, &container_client, &network, &task, Role::Leader).await;
let helper =
JanusContainer::new(TEST_NAME, &container_client, &network, &task, Role::Helper).await;

Expand All @@ -72,7 +64,6 @@ async fn daphne_janus() {

// This test places Janus in the leader role & Daphne in the helper role.
#[tokio::test(flavor = "multi_thread")]
#[ignore = "Daphne does not currently support DAP-07 (issue #1669)"]
#[cfg(feature = "testcontainer")]
async fn janus_daphne() {
static TEST_NAME: &str = "janus_daphne";
Expand Down Expand Up @@ -102,15 +93,7 @@ async fn janus_daphne() {
let container_client = container_client();
let leader =
JanusContainer::new(TEST_NAME, &container_client, &network, &task, Role::Leader).await;
let helper = Daphne::new(
TEST_NAME,
&container_client,
&network,
&task,
Role::Helper,
true,
)
.await;
let helper = Daphne::new(TEST_NAME, &container_client, &network, &task, Role::Helper).await;

// Run the behavioral test.
submit_measurements_and_verify_aggregate(
Expand All @@ -125,7 +108,6 @@ async fn janus_daphne() {
/// This test places Janus in the leader role and Daphne in the helper role. Janus is run
/// in-process, while Daphne is run in Docker.
#[tokio::test(flavor = "multi_thread")]
#[ignore = "Daphne does not currently support DAP-07 (issue #1669)"]
async fn janus_in_process_daphne() {
static TEST_NAME: &str = "janus_in_process_daphne";
install_test_trace_subscriber();
Expand Down Expand Up @@ -153,7 +135,6 @@ async fn janus_in_process_daphne() {
&network,
&task_builder.clone().build(),
Role::Helper,
true,
)
.await;
task_builder = task_builder.with_helper_aggregator_endpoint(
Expand Down
Loading