Skip to content

Commit

Permalink
Merge branch 'rjb/sw-tests' into 'master'
Browse files Browse the repository at this point in the history
chore(service-worker): rename SW test and add a few comments

# BOUN-990 

See merge request dfinity-lab/public/ic!17375
  • Loading branch information
r-birkner committed Jan 29, 2024
2 parents c7260b0 + f886c33 commit d14e28f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use anyhow::Result;

use ic_tests::boundary_nodes::boundary_nodes_integration::{
canister_allowlist_test, canister_test, denylist_test, direct_to_replica_options_test,
direct_to_replica_rosetta_test, direct_to_replica_test, http_canister_test, icx_proxy_test,
nginx_valid_config_test, prefix_canister_id_test, proxy_http_canister_test, reboot_test,
redirect_http_to_https_test, redirect_to_dashboard_test, redirect_to_non_raw_test, seo_test,
sw_test,
direct_to_replica_rosetta_test, direct_to_replica_test, http_canister_test, http_endpoint_test,
icx_proxy_test, nginx_valid_config_test, prefix_canister_id_test, proxy_http_canister_test,
reboot_test, redirect_http_to_https_test, redirect_to_dashboard_test, redirect_to_non_raw_test,
seo_test,
};
use ic_tests::boundary_nodes::setup::setup_ic_with_bn;
use ic_tests::boundary_nodes::{constants::BOUNDARY_NODE_NAME, helpers::BoundaryNodeHttpsConfig};
Expand All @@ -34,7 +34,7 @@ fn main() -> Result<()> {
.add_test(systest!(redirect_http_to_https_test))
.add_test(systest!(redirect_to_dashboard_test))
.add_test(systest!(redirect_to_non_raw_test))
.add_test(systest!(sw_test))
.add_test(systest!(http_endpoint_test))
.add_test(systest!(icx_proxy_test))
.add_test(systest!(direct_to_replica_test))
.add_test(systest!(direct_to_replica_rosetta_test))
Expand Down
10 changes: 5 additions & 5 deletions rs/tests/boundary_nodes/boundary_node_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use ic_tests::{
boundary_nodes_integration::{
asset_canister_test, canister_allowlist_test, canister_routing_test, canister_test,
denylist_test, direct_to_replica_options_test, direct_to_replica_rosetta_test,
direct_to_replica_test, http_canister_test, icx_proxy_test, nginx_valid_config_test,
prefix_canister_id_test, proxy_http_canister_test, reboot_test,
redirect_http_to_https_test, redirect_to_dashboard_test, redirect_to_non_raw_test,
seo_test, sw_test,
direct_to_replica_test, http_canister_test, http_endpoint_test, icx_proxy_test,
nginx_valid_config_test, prefix_canister_id_test, proxy_http_canister_test,
reboot_test, redirect_http_to_https_test, redirect_to_dashboard_test,
redirect_to_non_raw_test, seo_test,
},
setup::setup_ic_with_bn,
{constants::BOUNDARY_NODE_NAME, helpers::BoundaryNodeHttpsConfig},
Expand Down Expand Up @@ -40,7 +40,7 @@ fn main() -> Result<()> {
.add_test(systest!(redirect_http_to_https_test))
.add_test(systest!(redirect_to_dashboard_test))
.add_test(systest!(redirect_to_non_raw_test))
.add_test(systest!(sw_test))
.add_test(systest!(http_endpoint_test))
.add_test(systest!(icx_proxy_test))
.add_test(systest!(direct_to_replica_test))
.add_test(systest!(direct_to_replica_rosetta_test))
Expand Down
14 changes: 12 additions & 2 deletions rs/tests/src/boundary_nodes/boundary_nodes_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,10 @@ pub fn redirect_to_non_raw_test(env: TestEnv) {
.expect("test suite failed");
}

pub fn sw_test(env: TestEnv) {
// this tests the HTTP endpoint of the boundary node (anything that goes to icx-proxy)
// in particular, it ensure that the service worker uninstall script is served for
// anyone still having a service worker lingering around.
pub fn http_endpoint_test(env: TestEnv) {
let logger_orig = env.logger();

let boundary_node = env
Expand Down Expand Up @@ -1703,12 +1706,13 @@ pub fn sw_test(env: TestEnv) {

let futs = FuturesUnordered::new();

// fetching standard assets (html page, JS script) through icx-proxy
let host = host_orig.clone();
let logger = logger_orig.clone();
let asset_canister = asset_canister_orig.clone();
futs.push(rt.spawn({
let client = client.clone();
let name = "get index.html with sw.js include from root path";
let name = "get index.html with response verification";
info!(&logger, "Starting subtest {}", name);

async move {
Expand Down Expand Up @@ -1778,6 +1782,7 @@ pub fn sw_test(env: TestEnv) {
}
}));

// fetching assets from non-root path
let host = host_orig.clone();
let logger = logger_orig.clone();
let asset_canister = asset_canister_orig.clone();
Expand Down Expand Up @@ -1825,6 +1830,9 @@ pub fn sw_test(env: TestEnv) {
}
}));

// making sure the BN serves the uninstall script for any service worker
// request on the root path. This is necessary as clients that haven't visited
// a dapp for a long time, still have a service worker installed.
let host = host_orig.clone();
let logger = logger_orig.clone();
let asset_canister = asset_canister_orig.clone();
Expand Down Expand Up @@ -1871,6 +1879,8 @@ pub fn sw_test(env: TestEnv) {
}
}));

// Make sure, we don't serve our uninstall script on any other path than
// the root path.
let host = host_orig.clone();
let logger = logger_orig.clone();
let asset_canister = asset_canister_orig.clone();
Expand Down

0 comments on commit d14e28f

Please sign in to comment.