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

Expand testing data to work across all nodes #60

Open
4 tasks
mourginakis opened this issue Aug 14, 2023 · 0 comments
Open
4 tasks

Expand testing data to work across all nodes #60

mourginakis opened this issue Aug 14, 2023 · 0 comments
Assignees

Comments

@mourginakis
Copy link
Contributor

mourginakis commented Aug 14, 2023

For testing, Node Monitor does not make API calls, but instead loads pre-fetched json documents that store mock data.
These documents can be found in:
data/

Currently, this data was fetched and with filtered node_provider_id applied, so that it only returns Allusion's nodes.
https://ic-api.internetcomputer.org/api/v3/nodes?node_provider_id=rbn2y-6vfsb-gv35j-4cyvy-pzbdu-e5aum-jzjg6-5b4n5-vuguf-ycubq-zae

Because we are generalizing the software to work on all nodes, not just Allusion's nodes, it is important that we update all the mock data, as well as the tests, to use unfiltered data from the API.
https://ic-api.internetcomputer.org/api/v3/nodes

This data can be fetched with cURL in the following way:

$ curl "https://ic-api.internetcomputer.org/api/v3/nodes" -o t0.json

Requirements:

  • All files in data/ should be updated to be unfiltered API output.
    • data/t0.json (our 'control') should be updated with a generic response from the ic-api.
    • All other data/*.json files should be manually edited from t0.json to meet the specifications in node_monitor/conftest.py, creating more test cases if the current ones are no longer sufficient.
  • Tests in tests/test_node_monitor.py should be updated to be generic across all node providers, and should include tests when multiple node providers need to be messaged.

Excerpts from the code displaying both TODOs (for context):

## Create mock data for testing
## Data was pulled from the ic-api using cURL and stored in json files.
## This is data only from nodes with aviate labs provider id
## TODO: Update this data set to reflect multiple node providers
cached = {
"control": ic_api.get_nodes_from_file("data/t0.json"),
"one_node_down": ic_api.get_nodes_from_file("data/t1.json"),
"two_nodes_down": ic_api.get_nodes_from_file("data/t2.json"),
"one_node_change_subnet": ic_api.get_nodes_from_file("data/t3.json"),
"one_node_removed": ic_api.get_nodes_from_file("data/t4.json"),
}

# Set up a mock database so that we can test the broadcast() function
# without needing to access a database. This (temporarily) uses Allusion's
# node-provider-id (principal) on our test data stored in 'data/'
# TODO: expand these tests to work on all nodes, not just Allusion's nodes
# (currently all data in the 'data/' directory is filtered to only contain
# Allusion's nodes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant