Skip to content

Commit

Permalink
Add test for multiservice-discovery (#100)
Browse files Browse the repository at this point in the history
* Add integration test for mainnet targets

* Fix test suite

* Add Bazel dependencies

* Make explicit path to bin

* Add tests

* Add tests

* Add tests

* Add tests

* Add tests

* Add tests

* Add tests

* test new git index

* Add test data

* Add bazel

* Add IC_NODE test

* Add test for multiservice-discovery based on large02 testnet

* remove unused IC_NODE

* refactor child process

* Update checksum

* Repin bazel

* Test ls in bazel

* Test ls in bazel

* Test ls in bazel

* Test ls in bazel

* Test ls in bazel

* Fix Bazel test

* Add constants
  • Loading branch information
pietrodimarco-dfinity authored Jan 24, 2024
1 parent a93c44b commit c6a0501
Show file tree
Hide file tree
Showing 8 changed files with 868 additions and 12 deletions.
610 changes: 606 additions & 4 deletions Cargo.Bazel.lock

Large diffs are not rendered by default.

122 changes: 120 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::collections::{BTreeMap, BTreeSet};

use ic_types::PrincipalId;
use serde::{Serialize, Serializer};
use serde::{Deserialize, Serialize, Serializer};
use service_discovery::job_types::JobType;
use service_discovery::jobs::Job;

use crate::{builders::ConfigBuilder, contracts::target::TargetDto};

#[derive(Serialize, Debug, Clone, PartialEq, PartialOrd, Ord, Eq)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, PartialOrd, Ord, Eq)]
pub struct PrometheusStaticConfig {
pub targets: BTreeSet<String>,
pub labels: BTreeMap<String, String>,
Expand Down Expand Up @@ -51,10 +51,10 @@ fn get_endpoints(target_group: TargetDto, job: JobType) -> BTreeSet<String> {
.collect()
}

const IC_NAME: &str = "ic";
const IC_NODE: &str = "ic_node";
const IC_SUBNET: &str = "ic_subnet";
const JOB: &str = "job";
pub const IC_NAME: &str = "ic";
pub const IC_NODE: &str = "ic_node";
pub const IC_SUBNET: &str = "ic_subnet";
pub const JOB: &str = "job";
// TODO: Re-add the labels below once we resolve the issues with the public dashboard queries
// https://dfinity.atlassian.net/browse/OB-442
// const DC: &str = "dc";
Expand Down
21 changes: 21 additions & 0 deletions rs/ic-observability/multiservice-discovery/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ DEPS = [
"//rs/ic-observability/multiservice-discovery-shared"
]

DEV_DEPENDENCIES = [
"@crate_index_dre//:assert_cmd",
"@crate_index_dre//:tokio",
"@crate_index_dre//:tempdir",
"@crate_index_dre//:anyhow",
"@crate_index_dre//:reqwest",
"@crate_index_dre//:serde_json",
]

rust_binary(
name = "multiservice-discovery",
srcs = glob(["src/**/*.rs"]),
Expand Down Expand Up @@ -40,3 +49,15 @@ rust_test(
normal_dev = True,
) + DEPS,
)

rust_test(
name = "prom_targets_tests",
srcs = ["tests/tests.rs"],
data = [":multiservice-discovery"] + glob(["tests/test_data/**"]),
proc_macro_deps = all_crate_deps(
proc_macro_dev = True,
),
deps = all_crate_deps(
normal_dev = True,
) + DEPS + DEV_DEPENDENCIES,
)
7 changes: 7 additions & 0 deletions rs/ic-observability/multiservice-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ slog-term = { workspace = true }
tokio = { workspace = true }
url = { workspace = true }
warp = { workspace = true }

[dev-dependencies]
tempdir = "0.3.7"
reqwest = "0.11.23"
assert_cmd = "2.0.13"
anyhow = "1.0.79"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��������
Loading

0 comments on commit c6a0501

Please sign in to comment.