Code Monkey home page Code Monkey logo

Comments (3)

mtache avatar mtache commented on June 3, 2024

Thanks for raising this :)
Implementing tests as coroutines is definitely needed for this framework to scale.
Do you have any example of a test that would require to be run sequentially ?

from anta.

gusmb avatar gusmb commented on June 3, 2024

Thanks for raising this :) Implementing tests as coroutines is definitely needed for this framework to scale. Do you have any example of a test that would require to be run sequentially ?

I think it could be useful for large deployments, or where there are a vast number of tests with high correlation. For example, some BGP overlay session tests wouldn't make sense if the loopback is not defined, therefore you could cluster tests together, running the tests inside the cluster as co-routines and separate cluster tests in sequence. For instance:

  • Test group 1:
    • test_function_1
    • test_function_2
    • test_function_3
  • Test group 2:
    • test_function_4
    • test_function_5
    • test_function_6

Where usually the functions in test_group1 need to pass in order to make sense out of the tests in group 2, etc.

async def run_sequence(*functions: Awaitable[Any]) -> None:
  for function in functions:
    await function

async def run_parallel(*functions: Awaitable[Any]) -> None:
  await asyncio.gather(*functions)
await run_sequence(
  run_parallel(
    test_function_1(),
    test_function_2(),
    test_function_3()
  ),
  run_parallel(
    test_function_4(),
    test_function_5(),
    test_function_6()
  )
)

Other use cases could be managing how tests run across the inventory of devices (e.g., first spines, then the leafs, etc). This kind of flexibility may allow to easily optimize performance based on the inventory and test catalog...

from anta.

mtache avatar mtache commented on June 3, 2024

PR #122 implements asyncio in ANTA. However, we still cannot define a test hierarchy/dependency if some of them needs to be run sequentially: everything runs in parallel today.
However, we have written the anta_test decorator to factorise code that is identical across all tests.

from anta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.