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

feat(infrastructure): add availability test for apim #1327

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

arealmaas
Copy link
Collaborator

@arealmaas arealmaas commented Oct 21, 2024

Description

An availability test for the backend. For now will send a health-check request to web-api-so so verify that the service is up and running with the all dependencies. The health-endpoint in APIM will send requests to web-api-so by default, the other services are not exposed yet.

  • Adds an availability test towards our APIM. Will probe the deep version of the health-checks which checks third party URLs together with Redis and Postgres.
  • Will now only target web-api-so as it is the default backend. Should expose all services like this.
image

The frontend availability test:

image

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • Documentation is updated (either in docs-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)

Summary by CodeRabbit

  • New Features

    • Introduced a new parameter apimUrl for capturing the APIM instance URL across various environments (production, staging, test, yt01).
    • Added a new module for creating an availability test for the APIM instance, enhancing monitoring capabilities.
  • Enhancements

    • New output declaration for the Application Insights resource ID, allowing easier access to the resource identifier post-deployment.

@arealmaas arealmaas requested review from a team as code owners October 21, 2024 14:12
Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request involve the enhancement of Bicep templates used for Azure infrastructure deployment. A new parameter, apimUrl, is introduced across multiple environment-specific parameter files, including production, staging, test, and a specific environment. Additionally, a new module, apimAvailabilityTest, is added to create an availability test for the APIM instance, incorporating several parameters for configuration. The modifications aim to expand the monitoring capabilities of the APIM instance without altering existing parameters or modules.

Changes

File Change Summary
.azure/infrastructure/main.bicep Added parameter apimUrl and new module apimAvailabilityTest for APIM instance monitoring.
.azure/infrastructure/prod.bicepparam Added parameter apimUrl with default value 'https://platform.altinn.no/dialogporten'.
.azure/infrastructure/staging.bicepparam Added parameter apimUrl with default value 'https://platform.tt02.altinn.no/dialogporten'.
.azure/infrastructure/test.bicepparam Added parameter apimUrl with default value 'https://altinn-dev-api.azure-api.net/dialogporten'.
.azure/infrastructure/yt01.bicepparam Added parameter apimUrl with default value 'https://platform.yt01.altinn.cloud/dialogporten'.
.azure/modules/applicationInsights/availabilityTest.bicep Added parameters for availability test configuration and defined the availabilityTest resource.
.azure/modules/applicationInsights/create.bicep Added output appInsightsId for the Application Insights resource ID.

Possibly related PRs

Suggested reviewers

  • oskogstad
  • knuhau
  • MagnusSandgren

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@arealmaas arealmaas changed the title feat(azure): add availability test for apim feat(infrastructure): add availability test for apim Oct 21, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (3)
.azure/infrastructure/main.bicep (2)

42-43: LGTM! Consider adding constraints to the apimUrl parameter.

The new apimUrl parameter is correctly defined and aligns with the PR objective. To enhance robustness, consider adding constraints such as @minLength(1) or a regex pattern to ensure a valid URL format.


123-133: LGTM! Consider adding a comment for clarity.

The new apimAvailabilityTest module is well-implemented and aligns perfectly with the PR objective. It correctly uses the apimUrl parameter and targets the deep health check endpoint.

For improved readability, consider adding a brief comment above the module explaining its purpose and the significance of the '/health/deep' endpoint.

.azure/modules/applicationInsights/availabilityTest.bicep (1)

2-2: Consider renaming the name parameter for clarity.

Using a generic parameter name like name can lead to confusion. Renaming it to something more descriptive, such as availabilityTestName, enhances readability and maintainability.

Apply this diff to rename the parameter:

- param name string
+ param availabilityTestName string

And update its usage in the resource:

resource availabilityTest 'Microsoft.Insights/webtests@2022-06-15' = {
-  name: name
+  name: availabilityTestName
   ...
-  SyntheticMonitorId: name
+  SyntheticMonitorId: availabilityTestName
-  Name: name
+  Name: availabilityTestName
-  Description: 'Availability test for ${name}'
+  Description: 'Availability test for ${availabilityTestName}'
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 71698bf and ca2b1a0.

📒 Files selected for processing (7)
  • .azure/infrastructure/main.bicep (2 hunks)
  • .azure/infrastructure/prod.bicepparam (1 hunks)
  • .azure/infrastructure/staging.bicepparam (1 hunks)
  • .azure/infrastructure/test.bicepparam (1 hunks)
  • .azure/infrastructure/yt01.bicepparam (1 hunks)
  • .azure/modules/applicationInsights/availabilityTest.bicep (1 hunks)
  • .azure/modules/applicationInsights/create.bicep (1 hunks)
🧰 Additional context used
🔇 Additional comments (7)
.azure/modules/applicationInsights/create.bicep (1)

56-56: LGTM: New output for Application Insights resource ID.

The addition of appInsightsId output is appropriate and consistent with the module's purpose. It exposes the unique identifier of the Application Insights resource, which is useful for referencing this resource in other parts of the infrastructure, such as the new APIM availability test mentioned in the PR description.

.azure/infrastructure/prod.bicepparam (1)

52-52: LGTM: New apimUrl parameter added correctly.

The new apimUrl parameter has been added with the correct URL for the production environment. This aligns with the PR objectives to introduce an availability test for the Azure API Management (APIM).

To ensure consistency across environments and verify the usage of this parameter, please run the following script:

✅ Verification successful

Verified: apimUrl parameter is correctly defined and consistently used across all environments.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify apimUrl parameter across environments and its usage in main.bicep

# Test 1: Check apimUrl in all environment files
echo "Checking apimUrl in environment files:"
rg -n 'param apimUrl =' .azure/infrastructure/*.bicepparam

# Test 2: Verify usage in main.bicep
echo "\nChecking usage in main.bicep:"
rg -A 5 'apimUrl' .azure/infrastructure/main.bicep

Length of output: 1146

.azure/infrastructure/yt01.bicepparam (1)

51-51: LGTM: New apimUrl parameter added correctly.

The addition of the apimUrl parameter is consistent with the PR objectives and follows the pattern observed in other environment-specific files. This change supports the implementation of the APIM availability test without affecting existing parameters.

To ensure the correctness of the URL for this environment, please run the following verification:

✅ Verification successful

Verified: apimUrl for yt01 is correctly set.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the apimUrl parameter across all environment files

# Test: Check if the apimUrl is consistent across all environment files
echo "Checking apimUrl consistency across environment files:"
grep -H 'param apimUrl' .azure/infrastructure/*.bicepparam

# Test: Verify that the yt01 environment uses the correct URL
yt01_url=$(grep 'param apimUrl' .azure/infrastructure/yt01.bicepparam | awk -F"'" '{print $2}')
expected_url="https://platform.yt01.altinn.cloud/dialogporten"

if [ "$yt01_url" = "$expected_url" ]; then
    echo "yt01 apimUrl is correct: $yt01_url"
else
    echo "Error: yt01 apimUrl mismatch. Expected: $expected_url, Found: $yt01_url"
fi

Length of output: 1185

.azure/infrastructure/staging.bicepparam (1)

51-51: LGTM: New parameter apimUrl added correctly.

The new apimUrl parameter has been added correctly with an appropriate URL for the staging environment (tt02). This aligns with the PR objective of introducing an availability test for the Azure API Management (APIM).

To ensure consistency across environments, let's verify the apimUrl parameter in other environment files:

✅ Verification successful

Verification Successful: apimUrl parameter is consistent across all environments.

All environment files correctly include the apimUrl parameter with URLs appropriate to each environment's configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify apimUrl parameter across environment files

# Test: Check apimUrl in other environment files
echo "Checking apimUrl in other environment files:"
rg -n 'param apimUrl =' .azure/infrastructure/*.bicepparam

Length of output: 701

.azure/infrastructure/test.bicepparam (1)

51-52: LGTM: New parameter apimUrl added correctly.

The new parameter apimUrl has been added appropriately at the end of the file. The URL value 'https://altinn-dev-api.azure-api.net/dialogporten' seems consistent with a test environment setup.

To ensure consistency across environments and proper usage, let's verify the following:

✅ Verification successful

LGTM: apimUrl parameter is consistently added across all environments and correctly utilized in main.bicep.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify apimUrl parameter across environments and its usage in main.bicep

# Test 1: Check apimUrl in other environment files
echo "Checking apimUrl in other environment files:"
rg -n 'param apimUrl =' .azure/infrastructure/*.bicepparam

# Test 2: Verify usage in main.bicep
echo "\nChecking usage of apimUrl in main.bicep:"
rg -A 5 'apimUrl' .azure/infrastructure/main.bicep

Length of output: 1180

.azure/infrastructure/main.bicep (1)

Line range hint 1-324: Overall, the changes look good and achieve the PR objective.

The additions of the apimUrl parameter and the apimAvailabilityTest module successfully implement the availability test for APIM as intended. The changes are minimal, focused, and integrate well with the existing infrastructure setup without disrupting other resources.

The use of a separate module for the availability test promotes modularity and reusability, which is a good practice. The implementation aligns with the PR objective of probing the deep version of health checks for the APIM instance.

.azure/modules/applicationInsights/availabilityTest.bicep (1)

20-22: Verify the syntax of the 'hidden-link' tag key.

Ensure that the string interpolation in the tag key is correctly formatted. In Bicep, you might need to adjust the syntax to properly reference appInsightsId.

Would you like assistance in correcting the tag key syntax?

Copy link

@arealmaas arealmaas merged commit 1f9fa2b into main Oct 24, 2024
18 checks passed
@arealmaas arealmaas deleted the feat/availability-test branch October 24, 2024 12:00
arealmaas added a commit that referenced this pull request Oct 29, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.27.0](v1.26.3...v1.27.0)
(2024-10-29)


### Features

* Add restrictions to Transmissions reference hierarchy
([#1310](#1310))
([e3d53ca](e3d53ca))
* **graphql:** configure opentelemetry
([#1343](#1343))
([e31c08b](e31c08b))
* **infrastructure:** add availability test for apim
([#1327](#1327))
([1f9fa2b](1f9fa2b))
* **service:** configure opentelemetry
([#1342](#1342))
([513d5e4](513d5e4))
* **utils:** configure open telemetry tracing for masstransit in aspnet
package ([#1344](#1344))
([5ec3b84](5ec3b84))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Are Almaas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants