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: exclude threshold tests from all tests #1685

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

arealmaas
Copy link
Collaborator

@arealmaas arealmaas commented Jan 14, 2025

Description

Removed the threshold tests which are used only in performance tests, and moved the files under /performance. Also removed some unneded data files that were only required for testing towards at21

Related Issue(s)

  • N/A

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)

@arealmaas arealmaas requested a review from a team as a code owner January 14, 2025 14:59
Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

📝 Walkthrough

Walkthrough

The pull request introduces changes to the CI/CD workflow configuration and the organization of performance test scripts. It updates file paths in the .github/workflows/ci-cd-yt01.yml file to reflect a new directory structure for performance tests. Additionally, several import statements in test files have been modified or removed, indicating that certain functionalities are no longer included. The overall logic and control flow of the tests remain unchanged, focusing solely on file organization and path updates.

Changes

File Path Change Summary
.github/workflows/ci-cd-yt01.yml Updated file paths for performance test scripts to reflect new directory structure.
tests/k6/tests/enduser/all-tests.js Removed import and function call for enduserSearchWithThresholds.
tests/k6/tests/enduser/performance/enduserSearchWithThresholds.js Updated import path for run function.
tests/k6/tests/serviceowner/all-tests.js Removed imports and function calls for createDialogWithThresholds and serviceOwnerSearchWithThresholds.
tests/k6/tests/serviceowner/performance/createDialogWithThresholds.js Updated import path for run function.
tests/k6/tests/serviceowner/performance/serviceOwnerSearchWithThresholds.js Updated import path for run function.
tests/k6/scripts/generate_all_tests.sh Added conditional check to exclude processing of files in the performance directory.
tests/k6/scripts/generate_all_tests.ps1 Updated to filter JavaScript files based on their directory path to exclude those in /performance/.

Possibly related PRs

Suggested reviewers

  • dagfinno

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 799d0cf and 77934e7.

📒 Files selected for processing (1)
  • tests/k6/scripts/generate_all_tests.ps1 (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/k6/scripts/generate_all_tests.ps1
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Dry run deploy infrastructure / Deploy to test
  • GitHub Check: build / build-and-test

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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: 0

🧹 Nitpick comments (1)
tests/k6/scripts/generate_all_tests.sh (1)

18-18: Consider using more precise path matching.

The current pattern matching could unintentionally exclude files if "performance" appears anywhere in the path. Consider using a more precise check that specifically matches the /performance/ directory structure.

-    if [[ $DIRECTORY_PATH != *"performance"* ]]; then
+    if [[ $DIRECTORY_PATH != */performance/* ]]; then
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50b52cb and 31e5f27.

📒 Files selected for processing (1)
  • tests/k6/scripts/generate_all_tests.sh (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Dry run deploy infrastructure / Deploy to test
  • GitHub Check: build / build-and-test
🔇 Additional comments (3)
tests/k6/scripts/generate_all_tests.sh (3)

19-27: LGTM!

The file processing logic is well-structured and properly indented within the new condition block.


38-38: LGTM!

The formatting change follows common shell scripting conventions.


Line range hint 18-38: Verify the script with the new directory structure.

The changes align well with the PR objectives. Let's verify that:

  1. The script correctly identifies and excludes performance tests
  2. All expected test files are still being processed
✅ Verification successful

Script correctly handles the directory structure and test segregation

The verification confirms that:

  • Performance tests are properly identified and excluded across all directories
  • Regular test files and utilities are correctly included in the processing
  • No false positives or negatives in the test file selection
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the script's behavior with the new directory structure

# Test 1: Check if we have any remaining test files in performance directories
echo "Test files in performance directories:"
fd -e js . tests/k6 | grep -i "performance"

# Test 2: List all test files that will be processed (excluding performance)
echo -e "\nTest files that will be processed:"
fd -e js . tests/k6 | grep -v -i "performance" | grep -v "all-tests.js"

Length of output: 2845

oskogstad
oskogstad previously approved these changes Jan 14, 2025
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: 1

🧹 Nitpick comments (1)
tests/k6/scripts/generate_all_tests.ps1 (1)

Line range hint 1-24: Add error handling and improve logging.

The script would benefit from additional robustness improvements:

  1. Add validation for empty file list
  2. Add logging to show which files were included/excluded
  3. Add documentation about the performance directory requirement

Consider adding these improvements:

 param(
     [Parameter(Mandatory=$true)]
     [string]$DirectoryPath
 )
+
+# Document the performance directory requirement
+<# 
+.SYNOPSIS
+    Generates all-tests.js by combining test files from the performance directory.
+.PARAMETER DirectoryPath
+    The root directory to search for test files. Only files under a 'performance' subdirectory will be included.
+#>

 # Verify that the directory exists
 if (-not (Test-Path $DirectoryPath -PathType Container)) {
     Write-Error "The supplied directory does not exist!"
     exit 1
 }

 # Get all *.js files in the directory except for "all-tests.js"
 $jsFiles = Get-ChildItem -Path $DirectoryPath -Filter "*.js" | Where-Object { 
     $_.Name -ne "all-tests.js" -and 
     $_.Directory.FullName -like "*$(Join-Path 'performance' '*')"
 }
+
+# Validate that files were found
+if (-not $jsFiles) {
+    Write-Error "No .js files found in performance directory!"
+    exit 1
+}
+
+# Log included files
+Write-Output "Including the following test files:"
+$jsFiles | ForEach-Object { Write-Output "  - $($_.FullName)" }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 391ae4d and 799d0cf.

📒 Files selected for processing (2)
  • tests/k6/scripts/generate_all_tests.ps1 (1 hunks)
  • tests/k6/scripts/generate_all_tests.sh (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Dry run deploy infrastructure / Deploy to test
  • GitHub Check: build / build-and-test
🔇 Additional comments (4)
tests/k6/scripts/generate_all_tests.sh (3)

17-20: LGTM! The skip condition aligns with PR objectives.

The implementation correctly excludes both performance tests and the generated file itself. The pattern matching will work for any nested performance directories, which provides flexibility in the directory structure.


39-39: LGTM! Minor style improvement.

The removal of space before the redirection operator is a good practice for shell scripts.


Line range hint 1-39: Verify the impact on existing test files.

While the changes look good, let's verify that no critical test files are accidentally excluded by the new skip condition.

✅ Verification successful

Skip condition correctly identifies performance tests and includes regular tests

The verification confirms that:

  • Performance tests are properly isolated in dedicated "performance" directories
  • Regular test files like enduser-tests.js and serviceowner-tests.js are correctly included
  • No critical test files are accidentally excluded by the skip condition
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any test files in performance directories that might be critical

# List all JS files in any performance directory
echo "JS files in performance directories:"
fd -e js . | grep -i "performance"

# List all test files that will be included in all-tests.js
echo -e "\nJS files that will be included in all-tests.js:"
for dir in $(fd -t d . -E "performance"); do
  for js in "$dir"/*.js; do
    if [[ -f "$js" && ! "$js" =~ /performance/ && ! "$js" =~ all-tests.js$ ]]; then
      echo "$js"
    fi
  done
done

Length of output: 64775

tests/k6/scripts/generate_all_tests.ps1 (1)

Line range hint 25-39: LGTM! Output handling is well implemented.

The script properly handles:

  • UTF-8 encoding
  • Consistent line endings
  • No trailing newline

tests/k6/scripts/generate_all_tests.ps1 Outdated Show resolved Hide resolved
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