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

test: integration tests for akri and opcua checks #225

Merged
merged 16 commits into from
Jun 10, 2024

Conversation

vilit1
Copy link
Contributor

@vilit1 vilit1 commented May 22, 2024

Akri check integration tests

  1. organize check integration tests
  2. set up helpers for other service check tests (opcua, mq)
  3. see that --as-object needs love

image

Future tasks:

  1. improve akri checks --as-object
  2. improve opcua checks --as-object
  3. add mq check int tests
  4. fill out pre check int test

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Thank you for contributing to Azure IoT Operations tooling!

This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

Intent for Production

  • It is expected that pull requests made to default or core branches such as dev or main are of production grade. Corollary to this, any merged contributions to these branches may be deployed in a public release at any given time. By checking this box, you agree and commit to the expected production quality of code.

Basic expectations

  • If introducing new functionality or modified behavior, are they backed by unit and/or integration tests?
  • In the same context as above are command names and their parameter definitions accurate? Do help docs have sufficient content?
  • Have all the relevant unit and integration tests pass? i.e. pytest <project root> -vv. Please provide evidence in the form of a screenshot showing a succesful run of tests locally OR a link to a test pipeline that has been run against the change-set.
  • Have linter checks passed using the .pylintrc and .flake8 rules? Look at the CI scripts for example usage.
  • Have extraneous print or debug statements, commented out code-blocks or code-statements (if any) been removed from the surface area of changes?
  • Have you made an entry in HISTORY.rst which concisely explains your user-facing feature or change?

Azure IoT Operations CLI maintainers reserve the right to enforce any of the outlined expectations.

A PR is considered ready for review when all basic expectations have been met (or do not apply).

@vilit1 vilit1 marked this pull request as ready for review May 23, 2024 21:40
@vilit1 vilit1 requested a review from digimaun as a code owner May 23, 2024 21:40
@vilit1 vilit1 marked this pull request as draft May 23, 2024 21:57
@vilit1 vilit1 changed the title test: integration tests for akri checks test: integration tests for akri and opcua checks May 30, 2024
@vilit1 vilit1 marked this pull request as ready for review May 30, 2024 18:41
@Elsie4ever
Copy link
Contributor

you are right, also --as-object is currently not having consistent output as not including this flag, we can talk offline and maybe split some work?😋

@Elsie4ever
Copy link
Contributor

Elsie4ever commented Jun 5, 2024

want to double check if you tried to test these both with and without deployment some Akri and OPC UA resources? if not I can help to check as well

@vilit1
Copy link
Contributor Author

vilit1 commented Jun 10, 2024

new cluster, --include-dp args
image

@pytest.mark.parametrize("detail_level", ResourceOutputDetailLevel.list())
@pytest.mark.parametrize("resource_kind", AkriResourceKinds.list() + [None])
# TODO: figure out if name match should be a general test vs each service (minimize test runs)
@pytest.mark.parametrize("resource_match", [None, "*otel*", "akri-opcua*", generate_names()])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

leaning towards removing resource match testing here (and in opcua) and adding a todo for general resource match testing.

) -> Dict[str, Any]:
def pass_conditions(item: Dict[str, Any]) -> bool:
name = item["metadata"]["name"]
if resource_match and not fnmatch(name, resource_match):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can change into a single return

return any([ not resource_match and not prefixes, resource_match and fnmatch(name, resource_match), prefixes and any(name.startswith(prefix) for prefix in prefixes) ])

Copy link
Member

Choose a reason for hiding this comment

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

If the different if statements are checking for different scenarios, it's totally plausible to leave them as two separate statements - in case we need to change future logic in one but not another.

namespace_status = "success"
assert not runtime_resource[namespace]["conditions"]
evals = runtime_resource[namespace]["evaluations"]
kubectl_pods = get_kubectl_workload_items(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will need to make this into a helper function for mq pod checks

return {cond["name"]: cond for cond in result["postDeployment"]}, service_present


def sort_by_namespace(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should add in doc strings describing what the functions do...

@vilit1 vilit1 changed the base branch from dev to pipeline_int_tests June 10, 2024 21:20
@vilit1 vilit1 merged commit af719c7 into Azure:pipeline_int_tests Jun 10, 2024
17 checks passed
if isinstance(prefixes, str):
prefixes = [prefixes]
namespace_param = f"-n {namespace}" if namespace else "-A"
kubectl_items = run(f"kubectl get {service_type}s {namespace_param} -o json")
Copy link
Member

Choose a reason for hiding this comment

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

A word of caution for use with future checks - I believe certain CRDs may have a plural that isn't s

def test_check(init_setup, detail_level, services_map, post, pre):
ops_service, resources = services_map
resources = " ".join(resources)
command = f"az iot ops check --as-object --detail-level {detail_level} --ops-service {ops_service} "\
Copy link
Member

Choose a reason for hiding this comment

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

Is the --detail-level param tested elsewhere? Or will each services' checks need to iterate through available detail levels?

@vilit1 vilit1 deleted the akri_check_int branch October 2, 2024 16:47
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

Successfully merging this pull request may close these issues.

3 participants