Skip to content

Testing PoC: Modules should be more self-contained for testing #329

Closed

Description

Initial description

Modues are currently dependent on pre-deployed dependencies to work (e.g. VNETs, MSIs, etc.).

It would be better if we'd have a universal logic that allows modules to deploy their own dependencies instead. Ideally even in their own resource group (for Rg-Level resources) so that we can just remove the resource group instead of individual resources from it.

Update # 1:

It was decided to have a single dependency file per module and deploy it before the parameter file deployments - and remove the dependency resources afterwards again.

Current pipeline

The current pipeline looks like

image

There are different variants we could implement, as documented in the following:

Variant 1

There is one simply approach (which we discarded):
image

The following two pipeline variants will be implemented as part of a PoC:

Variant 2

image

Variant 3

image

Other options:

Update # 2:

Variant 4

image

Variant 5

image

Analysis Services Example
image

It was further decided to use plain resources (not our own modules) in the dependency file(s).

Note: Regardless of the implemented approach we should add features such as the Parameter-Matrix & Stage-template for Azure DevOps.

Activity

  1. added
    [cat] testing
    [prio] high
    on Nov 4, 2021
  2. modified the milestones: v 0.4, on Feb 21, 2022
  3. removed this from the milestone on Mar 30, 2022
  4. AlexanderSehr commented on May 19, 2022

    @AlexanderSehr
    ContributorAuthor

    Some notes for the idea in general:

    Pro

    • More complete removal (e.g. firewall RG would be removed)
    • Closer aligned to the ARM PG
    • Dependencies are directly tied to the module (instead of the overall dependency pipeline)
    • No dependency pipeline
    • Enable testing of the remaining modules (where dependencies resources are too expensive to keep around)

    Con

    • A LOT more code
    • Quite some work
    • Requires contributors to understand pipeline orchestration
    • Not obvious to understand
    • Does not work for all resources (1 exception with DiskEncryption due to the KeyRef) - may need some workaround
    • Duration of tests increase (due to dependency creation and removal)
  5. AlexanderSehr commented on Jun 10, 2022

    @AlexanderSehr
    ContributorAuthor

    Suggested changes (in discussion with Ahmad Abdalla (@ahmadabdalla))

    • TestRGName: customResourceGroupName: 'test-ms.analysisservices-servers-rg' -> moduleResourceGroupName: 'module-ms.analysisservices-servers-rg'
      • Also rename the resourceGroupName: 'validation-rg' variable to something like defaultResourceGroupName: 'validation-rg'
    • The stages template should use the default rg-name as a default for its input parameter moduleResourceGroupName: '$(defaultResourceGroupName)'. This helps us deal with pipelines that don't have dependencies implemented yet - though we still need to add some logic in the deploy step to skip itself it no template is found in the given/expected path (e.g. the dependency)

    Regarding dependencies.bicep (file(s))

    • Leaning towards the PGs main.test.bicep - using raw resources instead (aside from centralized concepts like diagnostics)
      • This would however render most of our pipeline 'unnecessay'. (which can of course be a good thing).
      • Some 'challenges' of that approach
        • We need to figure out how best to pull in tokens into the deployment file (e.g. what about deploymentSPID). Ideally it's not a new parameter for each token but e.g. a map/hashtable/object
        • One big bang failure if one of the test cases fails (may require us to add some code to drill into the issues and return the results to the user)
        • Resources are removed only after ALL resources were deployed (instead of e.g. min be removed directly after being done, without waiting for max)
        • References that required nested deployments may be tricky. For example a kv.getSecret() invocation on a just created key vault may not work but require a nested deployment. Similar to key-versions.
  6. MariusStorhaug commented on Jun 10, 2022

    @MariusStorhaug
    Contributor
  7. eriqua commented on Jun 14, 2022

    @eriqua
    Contributor

    Some additional considerations valid for all the approaches:

    • Coexistence between old and new approach: Converting all modules to the new approach will take quite some effort and we cannot commit to do it in one PR or in a short maintenance window. Thus we must ensure the new dependencies approach is able to run in parallel with the old one. For this reason we should introduce a check to verify if the module is using the new dependencies approach or not. Pipelines code should ideally work in both cases, possibly skip unnecessary steps (e.g. dependencies deployment) when not useful
    • Ensure new approach is valid at all scopes: this should already be the case after an update to the deployment validation job that will be presented together with the new approach, but it won't hurt to test this more thoroughly
    • Keep current dependencies pipeline for edge cases: we should discuss if keeping the current dependencies pipeline for edge cases that wouldn't be covered by the new approach, which are:
      • Modules requiring dependencies taking a long time to be deployed: e.g. the ones requiring a .vhd file which deployment takes about 2h
      • Module for which dependencies require a pipeline orchestrated approach to be deployed (e.g. the ones requiring kv secrets)
  8. AlexanderSehr commented on Jun 16, 2022

    @AlexanderSehr
    ContributorAuthor

    In a first step we decided to Implement variant 4 if we go with dedicated parameter files

  9. eriqua commented on Jun 17, 2022

    @eriqua
    Contributor

    Variant 5

    Some food for thoughts to discuss

    • random names: we must ensure them to be predictable to ensure idempotency
    • readme files: let's discuss if removing examples from the readme since they would be included in the tests OR if we want to extract the specific module snippet only (remove dependencies)
    • should we still commit to support arm/json until Bicep GA?
  10. AlexanderSehr commented on Jun 23, 2022

    @AlexanderSehr
    ContributorAuthor

    The team will go forward with Variant 5. To this end I created the issue #1583 which should be followed up by subsequent issues to implement the test files.

  11. changed the title [-]Testing: Modules should be more self-contained for testing[/-] [+]Testing PoC: Modules should be more self-contained for testing[/+] on Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

[cat] testing[prio] highenhancement

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions