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

Development: Improve execution speed of Playwright tests #9817

Merged
merged 13 commits into from
Nov 21, 2024

Conversation

muradium
Copy link
Contributor

@muradium muradium commented Nov 18, 2024

Checklist

General

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the client coding and design guidelines.

Motivation and Context

Currently, execution of Playwright tests takes a long time due to a lot of tests running sequentially.

Description

This PR separates sequentially running tests that do not trigger any programming exercise submissions or do not assert the results of submissions into another category. These tests will now run in parallel to @fast tests, but with larger timeout. These tests are now tagged with @slow annotation. All tests that assert the programming exercise submission results are now tagged as @sequential to make the purpose more clear, and run sequentially to ensure stability.

Steps for Testing

  • Code Review: Ensure that tests pass for valid reasons, test setup is valid and check the code quality.
  • Run the tests: Tests are checked by automatic run in CI environment. You may check the results of the bamboo build run or run tests locally.

Steps for running the tests locally

  1. Navigate to src/tests/playwright
  2. Configure Playwright using playwright.env file based on your local setup. Current configuration should work for default Artemis setup.
  3. Run npm install && npm run playwright:setup
  4. Run tests with the following command and confirm that they pass:
  • npm run playwright:test
  1. Check if the test run generated a correct single result file as ./test-reports/results.xml

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

  • New Features

    • Enhanced organization of test suites with improved tagging for execution speed.
    • Introduced parallel execution for faster tests and a dedicated configuration for sequential tests.
  • Bug Fixes

    • Adjusted test tags to better reflect execution characteristics, improving test categorization.
  • Documentation

    • Updated configuration files to clarify test project definitions and execution strategies.
  • Chores

    • Modified package scripts for streamlined test execution and reporting.

@muradium muradium changed the title Feature/playwright/improve test execution times Feature: Improve execution speed of Playwright tests Nov 18, 2024
@muradium muradium changed the title Feature: Improve execution speed of Playwright tests Development: Improve execution speed of Playwright tests Nov 18, 2024
@muradium muradium marked this pull request as ready for review November 18, 2024 21:30
@muradium muradium requested a review from a team as a code owner November 18, 2024 21:30
Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

makes sense and halves the execution time 👍

Copy link

coderabbitai bot commented Nov 18, 2024

Walkthrough

The changes in this pull request primarily involve modifications to the test suites for various exam-related functionalities in the Playwright framework. The updates include adjustments to test categorization through the addition and removal of tags, specifically changing tags from @slow to @fast or @sequential. New configurations for test execution modes have been introduced, allowing for parallel and sequential test runs. The overall structure and logic of the tests remain unchanged, focusing on enhancing organization and clarity within the test suites.

Changes

File Path Change Summary
src/test/playwright/e2e/exam/ExamAssessment.spec.ts Updated test.describe calls with specific tags; added test.describe.configure({ mode: 'serial' }) for "Exam assessment"; removed tag: '@slow'.
src/test/playwright/e2e/exam/ExamParticipation.spec.ts Removed tag: '@slow' from main block; added to nested blocks; added tag: '@sequential' for "Normal Hand-in".
src/test/playwright/e2e/exam/ExamResults.spec.ts Removed tag: '@slow'; tagged programming exercises with @sequential.
src/test/playwright/e2e/exam/ExamTestRun.spec.ts Changed tag from @slow to @fast.
src/test/playwright/e2e/exam/test-exam/TestExamCreationDeletion.spec.ts Changed tag from @slow to @fast.
src/test/playwright/e2e/exam/test-exam/TestExamManagement.spec.ts Changed tag from @slow to @fast.
src/test/playwright/e2e/exercise/ExerciseImport.spec.ts Removed tag: '@slow'; updated individual tests with @fast and @sequential tags.
src/test/playwright/e2e/exercise/modeling/ModelingExerciseParticipation.spec.ts Changed tag from @slow to @fast.
src/test/playwright/e2e/exercise/programming/ProgrammingExerciseAssessment.spec.ts Changed tag from @slow to @sequential.
src/test/playwright/e2e/exercise/programming/ProgrammingExerciseManagement.spec.ts Changed tag from @slow to @fast.
src/test/playwright/e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts Changed tag from @slow to @sequential.
src/test/playwright/e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts Changed tag from @slow to @sequential.
src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseAssessment.spec.ts Changed tag from @slow to @fast.
src/test/playwright/package.json Updated playwright:test script to run playwright:test:parallel and playwright:test:sequential; modified merge-reports script.
src/test/playwright/playwright.config.ts Redefined project configurations for fast-tests and added sequential-tests project for better categorization.

Possibly related PRs

Suggested labels

ready for review, refactoring

Suggested reviewers

  • SimonEntholzer
  • krusche
  • dmytropolityka
  • coolchock
  • EneaGore

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/test/playwright/e2e/exam/ExamAssessment.spec.ts

Oops! Something went wrong! :(

ESLint: 9.14.0

TypeError: Error while loading rule '@typescript-eslint/no-unused-expressions': Cannot read properties of undefined (reading 'allowShortCircuit')
Occurred while linting /src/test/playwright/e2e/exam/ExamAssessment.spec.ts
at Object.create (/node_modules/@typescript-eslint/eslint-plugin/node_modules/eslint/lib/rules/no-unused-expressions.js:75:13)
at create (/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unused-expressions.js:28:32)
at Object.create (/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:31:20)
at createRuleListeners (/node_modules/eslint/lib/linter/linter.js:943:21)
at /node_modules/eslint/lib/linter/linter.js:1068:84
at Array.forEach ()
at runRules (/node_modules/eslint/lib/linter/linter.js:999:34)
at #flatVerifyWithoutProcessors (/node_modules/eslint/lib/linter/linter.js:1911:31)
at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/node_modules/eslint/lib/linter/linter.js:1992:49)
at Linter._verifyWithFlatConfigArray (/node_modules/eslint/lib/linter/linter.js:2081:21)


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 or @coderabbitai title 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

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

🧹 Outside diff range and nitpick comments (15)
src/test/playwright/package.json (1)

19-19: Consider adding explicit worker count control

The parallel execution might benefit from an explicit --workers parameter to prevent system resource exhaustion. The optimal number could be based on the CI/CD environment's capabilities.

-        "playwright:test:parallel": "cross-env PLAYWRIGHT_JUNIT_OUTPUT_NAME=./test-reports/results-parallel.xml playwright test e2e --project=fast-tests --project=slow-tests",
+        "playwright:test:parallel": "cross-env PLAYWRIGHT_JUNIT_OUTPUT_NAME=./test-reports/results-parallel.xml playwright test e2e --project=fast-tests --project=slow-tests --workers=${MAX_WORKERS:-4}",
src/test/playwright/e2e/exercise/modeling/ModelingExerciseParticipation.spec.ts (1)

Line range hint 11-31: Consider enhancing test isolation and cleanup robustness.

While the test is well-structured, there are opportunities to improve its reliability:

  1. Consider using unique identifiers in course/exercise names to prevent any potential conflicts in parallel execution
  2. Add error handling in cleanup to ensure resources are deleted even if tests fail

Here's a suggested improvement:

 test.beforeEach('Create course', async ({ login, courseManagementAPIRequests, exerciseAPIRequests }) => {
     await login(admin);
-    course = await courseManagementAPIRequests.createCourse();
+    // Add unique identifier to prevent conflicts in parallel execution
+    course = await courseManagementAPIRequests.createCourse({
+        title: `Modeling Test Course ${Date.now()}-${Math.random().toString(36).substring(7)}`
+    });
     await courseManagementAPIRequests.addStudentToCourse(course, studentOne);
     modelingExercise = await exerciseAPIRequests.createModelingExercise({ course });
 });

 test.afterEach('Delete course', async ({ courseManagementAPIRequests }) => {
-    await courseManagementAPIRequests.deleteCourse(course, admin);
+    // Ensure cleanup runs even if test fails
+    try {
+        if (course?.id) {
+            await courseManagementAPIRequests.deleteCourse(course, admin);
+        }
+    } catch (error) {
+        console.error('Failed to cleanup test resources:', error);
+        throw error;
+    }
 });
src/test/playwright/playwright.config.ts (2)

35-41: Consider adding explicit worker configuration and reviewing test categorization strategy.

While the configuration for fast tests looks good overall, consider these improvements:

  1. Add explicit workers configuration to optimize parallel execution for fast tests
  2. The pattern ^[^@]*$ might accidentally include untagged tests that should be categorized. Consider requiring explicit @fast tags for better maintainability.
 {
     name: 'fast-tests',
-    grep: /@fast|^[^@]*$/,
+    grep: /@fast/,
     timeout: (parseNumber(process.env.FAST_TEST_TIMEOUT_SECONDS) ?? 45) * 1000,
+    workers: parseNumber(process.env.FAST_TEST_WORKERS) ?? 'max',
     use: { ...devices['Desktop Chrome'] },
 },

Line range hint 1-58: Documentation improvements needed for test configuration.

Please add comprehensive documentation about:

  1. Required environment variables and their default values
  2. Recommended commands for running different test categories
  3. Migration guide for moving tests between categories

Add this documentation at the top of the file:

 import { defineConfig, devices } from '@playwright/test';
 import dotenv from 'dotenv';
 import { parseNumber } from './support/utils';
+
+/**
+ * Test Configuration Guide
+ * -----------------------
+ * Environment Variables:
+ * - TEST_TIMEOUT_SECONDS: Global timeout (default: 180)
+ * - TEST_RETRIES: Number of retries (default: 2)
+ * - TEST_WORKER_PROCESSES: Global worker count (default: 3)
+ * - FAST_TEST_TIMEOUT_SECONDS: Timeout for @fast tests (default: 45)
+ * - SLOW_TEST_TIMEOUT_SECONDS: Timeout for @slow tests (default: 180)
+ * - SEQUENTIAL_TEST_TIMEOUT_SECONDS: Timeout for @sequential tests (default: 180)
+ * 
+ * Running Tests:
+ * - All tests: npx playwright test
+ * - Fast tests only: npx playwright test --project=fast-tests
+ * - Sequential tests: npx playwright test --project=sequential-tests
+ * 
+ * Test Categories:
+ * - @fast: Quick tests that can run in parallel
+ * - @slow: Longer running tests that can run in parallel
+ * - @sequential: Tests that must run sequentially (e.g., submission tests)
+ */
src/test/playwright/e2e/exam/test-exam/TestExamCreationDeletion.spec.ts (1)

Line range hint 33-77: Consider optimizing test performance further

While the test is correctly tagged as '@fast', there are opportunities to make it even faster:

  1. Consider moving more setup operations to API calls instead of UI interactions
  2. The exam creation test could potentially be split into:
    • A fast API test for validation logic
    • A minimal UI test for critical paths only

This would align better with the PR's goal of improving test execution speed.

src/test/playwright/e2e/exercise/programming/ProgrammingExerciseAssessment.spec.ts (1)

Line range hint 94-98: Consider addressing the TODO comment about complaint functionality.

The commented code block indicates a pending fix for the accept/reject complaint functionality. This might affect the completeness of the test coverage.

Would you like me to:

  1. Help implement the fix for the accept/reject complaint functionality?
  2. Create a GitHub issue to track this TODO?
src/test/playwright/e2e/exam/test-exam/TestExamManagement.spec.ts (1)

14-14: Consider adding custom timeouts for resource-intensive tests.

While the suite is correctly tagged as @fast, the programming exercise creation test might need a longer timeout than other tests in this suite.

Consider adding a custom timeout for the programming exercise test:

-        test('Adds a programming exercise', async ({ page, examManagement, examExerciseGroups, programmingExerciseCreation }) => {
+        test('Adds a programming exercise', { timeout: 90000 }, async ({ page, examManagement, examExerciseGroups, programmingExerciseCreation }) => {
src/test/playwright/e2e/exam/ExamTestRun.spec.ts (1)

Line range hint 22-45: Consider optimizing test setup for faster execution

To improve test execution speed, consider moving the course and exam creation to a beforeAll hook instead of beforeEach. This would reduce the number of API calls and setup time significantly.

- test.beforeEach('Create course', async ({ login, examExerciseGroupCreation, courseManagementAPIRequests, examAPIRequests }) => {
+ test.beforeAll('Create course', async ({ login, examExerciseGroupCreation, courseManagementAPIRequests, examAPIRequests }) => {

Note: Ensure that tests are independent and don't modify the shared resources in a way that affects other tests.

src/test/playwright/e2e/exercise/ExerciseImport.spec.ts (1)

Test categorization needs attention across the codebase

The verification reveals inconsistencies in test categorization:

  • Several exam-related tests are still using the deprecated @slow tag that should be removed
  • Programming exercise tests in ExerciseImport.spec.ts correctly use @sequential, but other programming submission tests lack proper tagging
  • Non-programming tests are inconsistently tagged with @fast
🔗 Analysis chain

Line range hint 20-150: Verify consistent test categorization across the codebase

Let's ensure that the test categorization pattern is consistently applied across all Playwright test files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify test categorization consistency across Playwright tests
# Expected patterns:
# - Programming submission tests should use @sequential
# - Other tests should use @fast
# - @slow tag should be removed

echo "Checking for any remaining @slow tags..."
rg "tag: '@slow'" "src/test/playwright"

echo "Checking programming submission tests for @sequential tag..."
rg -B2 "makeSubmissionAndVerifyResults|submitSolution" "src/test/playwright" | rg "tag: '@sequential'"

echo "Checking non-programming tests for @fast tag..."
rg -B2 "submit\(\)|submitExercise\(\)" "src/test/playwright" | rg "tag: '@fast'"

Length of output: 1739


Script:

#!/bin/bash
# Let's try a more targeted search for test categorization patterns

echo "Checking programming exercise tests with their tags..."
rg -B3 "programming.*exercise" "src/test/playwright" | rg "test\(.*tag:"

echo "Checking all test tags in playwright tests..."
rg "test\(.*tag: '@[^']*'" "src/test/playwright" -A1

echo "Checking specifically for programming submission patterns..."
rg -B5 "programming.*exercise.*submission" "src/test/playwright"

Length of output: 10609

src/test/playwright/e2e/exam/ExamResults.spec.ts (1)

138-168: Fix potential variable scope issues in switch statement

The switch statement contains variable declarations that could leak between cases. While this isn't causing issues currently, it's better to follow best practices and wrap case blocks in curly braces.

Consider refactoring the switch statement like this:

 switch (testCase.exerciseType) {
     case ExerciseType.TEXT: {
         await examResultsPage.checkTextExerciseContent(exercise.id!, exercise.additionalData!.textFixture!);
         await examResultsPage.checkAdditionalFeedback(exercise.id!, 7, 'Good job');
         break;
     }
     case ExerciseType.PROGRAMMING: {
         await examResultsPage.checkProgrammingExerciseAssessments(exercise.id!, 'Wrong', 7);
         await examResultsPage.checkProgrammingExerciseAssessments(exercise.id!, 'Correct', 6);
         const taskStatuses: ProgrammingExerciseTaskStatus[] = [
             ProgrammingExerciseTaskStatus.SUCCESS,
             ProgrammingExerciseTaskStatus.SUCCESS,
             ProgrammingExerciseTaskStatus.SUCCESS,
             ProgrammingExerciseTaskStatus.FAILURE,
             ProgrammingExerciseTaskStatus.FAILURE,
             ProgrammingExerciseTaskStatus.FAILURE,
             ProgrammingExerciseTaskStatus.FAILURE,
         ];
         await examResultsPage.checkProgrammingExerciseTasks(exercise.id!, taskStatuses);
         break;
     }
     case ExerciseType.QUIZ: {
         await examResultsPage.checkQuizExerciseScore(exercise.id!, 5, 10);
         const studentAnswers = [true, false, true, false];
         const correctAnswers = [true, true, false, false];
         await examResultsPage.checkQuizExerciseAnswers(exercise.id!, studentAnswers, correctAnswers);
         break;
     }
     case ExerciseType.MODELING: {
         await examResultsPage.checkAdditionalFeedback(exercise.id!, 5, 'Good');
         await examResultsPage.checkModellingExerciseAssessment(exercise.id!, 'class Class', 'Wrong', -1);
         await examResultsPage.checkModellingExerciseAssessment(exercise.id!, 'abstract class Abstract', 'Neutral', 0);
         break;
     }
 }
🧰 Tools
🪛 Biome

[error] 146-154: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 159-159: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 160-160: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

src/test/playwright/e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts (4)

Line range hint 58-61: Consider improving C language test skip logic

The current skip logic for C tests uses an inline condition. Consider extracting this into a helper function or test tag for better maintainability and clarity.

-        if (programmingLanguage !== ProgrammingLanguage.C || process.env.PLAYWRIGHT_DB_TYPE !== 'Postgres') {
+        const shouldSkipCTest = programmingLanguage === ProgrammingLanguage.C && process.env.PLAYWRIGHT_DB_TYPE === 'Postgres';
+        test.skip(shouldSkipCTest, 'C tests are not supported in Postgres setup');
+        if (!shouldSkipCTest) {

Line range hint 6-11: Consider using dynamic test data loading

The test fixtures are imported with hardcoded paths. Consider implementing a dynamic test data loader to improve maintainability and make it easier to add new test cases.

// Example test data loader
const loadTestData = (language: ProgrammingLanguage, scenario: string) => 
  import(`../../../fixtures/exercise/programming/${language}/${scenario}/submission.json`);

Line range hint 251-254: Security: Avoid including credentials in Git URLs

Including passwords in Git URLs is a security risk as they might be logged or exposed. Consider using Git credentials helper or environment variables for authentication.

-    repoUrl = repoUrl.replace(student.username!, `${student.username!}:${student.password!}`);
-    repoUrl = repoUrl.replace(`:**********`, ``);
+    // Use Git credentials helper
+    await gitClient.configureAuth(student.username!, student.password!);

Line range hint 257-258: Improve repository cleanup reliability

The repository cleanup should be moved to a try/finally block to ensure cleanup even if the test fails.

-    await fs.rmdir(`./test-exercise-repos/${repoName}`, { recursive: true });
-    await page.goto(`courses/${course.id}/exercises/${exercise.id!}`);
+    try {
+        await page.goto(`courses/${course.id}/exercises/${exercise.id!}`);
+        const resultScore = await programmingExerciseOverview.getResultScore();
+        await expect(resultScore.getByText(submission.expectedResult)).toBeVisible();
+    } finally {
+        await fs.rm(`./test-exercise-repos/${repoName}`, { recursive: true, force: true });
+    }
src/test/playwright/e2e/exam/ExamParticipation.spec.ts (1)

261-261: Consider using '@fast' tag for Exam announcements

While the '@slow' tag works, these tests might be better suited for the '@fast' tag because:

  • They test real-time communication features
  • Don't involve submission results or complex UI workflows
  • Could potentially run faster in parallel
-    test.describe('Exam announcements', { tag: '@slow' }, () => {
+    test.describe('Exam announcements', { tag: '@fast' }, () => {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 745c7f7 and b5caaf4.

📒 Files selected for processing (15)
  • src/test/playwright/e2e/exam/ExamAssessment.spec.ts (6 hunks)
  • src/test/playwright/e2e/exam/ExamParticipation.spec.ts (5 hunks)
  • src/test/playwright/e2e/exam/ExamResults.spec.ts (2 hunks)
  • src/test/playwright/e2e/exam/ExamTestRun.spec.ts (1 hunks)
  • src/test/playwright/e2e/exam/test-exam/TestExamCreationDeletion.spec.ts (1 hunks)
  • src/test/playwright/e2e/exam/test-exam/TestExamManagement.spec.ts (1 hunks)
  • src/test/playwright/e2e/exercise/ExerciseImport.spec.ts (4 hunks)
  • src/test/playwright/e2e/exercise/modeling/ModelingExerciseParticipation.spec.ts (1 hunks)
  • src/test/playwright/e2e/exercise/programming/ProgrammingExerciseAssessment.spec.ts (1 hunks)
  • src/test/playwright/e2e/exercise/programming/ProgrammingExerciseManagement.spec.ts (1 hunks)
  • src/test/playwright/e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts (1 hunks)
  • src/test/playwright/e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts (1 hunks)
  • src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseAssessment.spec.ts (1 hunks)
  • src/test/playwright/package.json (1 hunks)
  • src/test/playwright/playwright.config.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/test/playwright/e2e/exercise/programming/ProgrammingExerciseManagement.spec.ts
🧰 Additional context used
🪛 Biome
src/test/playwright/e2e/exam/ExamResults.spec.ts

[error] 146-154: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 159-159: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 160-160: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

🔇 Additional comments (25)
src/test/playwright/package.json (2)

20-20: LGTM! Well-structured sequential execution configuration

The script correctly enforces sequential execution with a single worker, which is essential for tests that must run in order (e.g., programming exercise submissions).


18-18: Consider the implications of --continue-on-error flag

While the flag ensures all tests are executed, it might mask critical failures in the parallel tests before running sequential tests. Consider adding a post-execution validation step to ensure no critical tests failed.

src/test/playwright/e2e/exercise/modeling/ModelingExerciseParticipation.spec.ts (1)

7-7: LGTM! The @fast tag is appropriate for this test suite.

The change from @slow to @fast aligns with the PR objectives since this test suite:

  • Doesn't trigger programming exercise submissions
  • Doesn't assert submission results
  • Operates in isolation with its own course/exercise
  • Can safely run in parallel with other tests
src/test/playwright/e2e/exercise/quiz-exercise/QuizExerciseAssessment.spec.ts (1)

Line range hint 8-53: Test implementation looks good!

The test implementation follows good practices:

  • Proper setup/teardown using beforeEach/afterEach hooks
  • Focused test cases with clear assertions
  • Efficient use of API requests for operations
  • Good flaky test handling with retry configuration
src/test/playwright/e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts (1)

9-9: LGTM! Tag change aligns with PR objectives.

The change from @slow to @sequential is appropriate for this test suite because:

  1. It involves programming exercise submission and result assertion
  2. It has complex setup/teardown with course creation/deletion
  3. Sequential execution is necessary to maintain test stability
src/test/playwright/e2e/exam/test-exam/TestExamCreationDeletion.spec.ts (1)

26-26: LGTM: Tag change aligns with PR objectives

The change from '@slow' to '@fast' is appropriate as this test suite doesn't involve programming exercise submissions or assert submission results.

src/test/playwright/e2e/exercise/programming/ProgrammingExerciseAssessment.spec.ts (1)

20-20: LGTM! Appropriate tag for sequential test execution.

The change from @slow to @sequential is correct as this test must run sequentially due to:

  • Programming exercise submission verification
  • Time-sensitive operations with due dates
  • Complex state changes through multiple user roles
src/test/playwright/e2e/exam/test-exam/TestExamManagement.spec.ts (1)

14-14: Verify parallel execution safety for programming exercise tests.

The change from @slow to @fast tag aligns with the PR objectives since these tests don't assert programming exercise submissions. However, the programming exercise creation test might be resource-intensive.

Let's verify if there are any resource conflicts when running in parallel:

✅ Verification successful

Based on the search results, I can now generate the final response:

The tag change from @slow to @fast is appropriate for this test suite.

The codebase search reveals that programming exercise creation tests are well-isolated across different test files, and the test suite in question (TestExamManagement.spec.ts) only contains basic UI interactions for adding a programming exercise to an exam. The actual resource-intensive operations (like repository creation) are mocked or handled by the test fixtures, making parallel execution safe.

Key findings:

  • The programming exercise creation test in this file only handles UI interactions and form submissions
  • Resource-intensive operations are abstracted through fixtures (programmingExerciseCreation)
  • Other test files containing programming exercise tests are properly tagged and isolated
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar programming exercise creation tests that might run in parallel
ast-grep --pattern 'test($_, async ({ $$ }) => {
  $$$
  programmingExerciseCreation
  $$$
})'

Length of output: 220


Script:

#!/bin/bash
# Let's try a different approach to search for programming exercise creation patterns
rg -l "programmingExercise" --type ts

# Then look for test files containing programming exercise related tests
rg "test\(.*programming.*exercise.*" --type ts -A 5

Length of output: 28273

src/test/playwright/e2e/exam/ExamTestRun.spec.ts (1)

Line range hint 20-45: Well-structured test setup and organization

The test suite follows best practices with:

  • Clear separation of setup and teardown
  • Proper async/await usage
  • Well-organized test groups
  • Focused assertions
src/test/playwright/e2e/exercise/ExerciseImport.spec.ts (4)

20-20: LGTM! Appropriate tag removal

The removal of the @slow tag from the describe block is correct since individual tests now have specific tags for better categorization.


42-42: LGTM! Appropriate use of @fast tag

The text exercise import test is correctly tagged as @fast since it doesn't involve programming exercise submissions or complex result assertions.


72-72: LGTM! Appropriate use of @fast tag

The quiz exercise import test is correctly tagged as @fast since it doesn't involve programming exercise submissions or complex result assertions.


126-150: LGTM! Appropriate use of @Sequential tag

The programming exercise import test is correctly tagged as @sequential since it involves programming exercise submission and result verification, which aligns with the PR's objectives for test categorization.

src/test/playwright/e2e/exam/ExamResults.spec.ts (1)

129-132: LGTM: Test categorization aligns with PR objectives

The conditional tagging implementation correctly categorizes programming exercise tests as @sequential and others as @slow, which aligns with the PR's goal of improving test execution speed while maintaining stability for programming exercise tests.

src/test/playwright/e2e/exercise/programming/ProgrammingExerciseParticipation.spec.ts (1)

23-23: LGTM: Tag change aligns with test execution strategy

The change from @slow to @sequential correctly categorizes these tests as requiring sequential execution, which is appropriate given they involve programming exercise submissions and build result verification.

src/test/playwright/e2e/exam/ExamParticipation.spec.ts (5)

20-20: LGTM: Removal of '@slow' tag from main describe block

The removal of the '@slow' tag from the main describe block is appropriate since individual test blocks now have specific tags for better granularity in test execution.


46-46: LGTM: '@slow' tag for Early Hand-in tests

The '@slow' tag is correctly applied here as these tests:

  • Don't assert submission results
  • Focus on UI navigation and submission workflow
  • Can safely run in parallel with other tests

120-120: LGTM: '@slow' tag for Early hand-in with continue tests

The '@slow' tag is appropriate as these tests:

  • Focus on UI interactions and page reloads
  • Don't involve critical submission assertions
  • Can run in parallel with other tests

224-224: LGTM: '@Sequential' tag for Normal Hand-in tests

The '@Sequential' tag is correctly applied as these tests:

  • Assert actual submission results
  • Use time-sensitive operations (30-second window)
  • Need to run sequentially to maintain stability

Line range hint 224-260: Verify timeout settings for time-sensitive tests

The Normal Hand-in tests use a 30-second window for exam completion. Ensure this timing is sufficient when running sequentially.

✅ Verification successful

Let me analyze the test timeouts and generate additional verification scripts to check the test configuration and sequential test execution settings.


30-second exam window is sufficient for sequential tests

The verification shows that:

  1. The test is properly tagged with @sequential, ensuring it runs in isolation
  2. Sequential tests have a generous timeout of 180 seconds (3 minutes) as configured in playwright.config.ts
  3. The 30-second exam window is only used for the actual exam submission timing, not the test execution timing
  4. Other exam-related tests use similar short durations (1-2 minutes) for exam windows successfully

The timing is appropriate because:

  • Sequential tests run one at a time, eliminating concurrency issues
  • The test performs simple text exercise submission
  • The configured test timeout (180s) provides ample buffer for potential delays
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for timeout configurations in test setup
rg -A 2 "setTimeout|timeout:" src/test/playwright/

Length of output: 6427


Script:

#!/bin/bash
# Search for sequential test configurations and related timing settings
rg -A 2 "@sequential|test.describe.*sequential" src/test/playwright/

# Search for exam duration settings in the test files
rg -A 2 "endDate.*dayjs" src/test/playwright/

Length of output: 9635

src/test/playwright/e2e/exam/ExamAssessment.spec.ts (5)

56-57: LGTM: Serial mode configuration ensures correct test execution order.

The addition of test.describe.configure({ mode: 'serial' }) ensures that all nested tests run sequentially, which is crucial for maintaining the integrity of the exam assessment flow.


62-62: LGTM: Appropriate test categorization with @Sequential tag.

The @sequential tag correctly identifies this test block as requiring sequential execution due to its programming exercise submission assertions, aligning with the PR's goal of improving test organization.


157-157: LGTM: Appropriate test categorization with @slow tag.

The @slow tag is correctly applied as this test involves automatic assessment and timing-based operations but doesn't directly assert submission results.


187-187: LGTM: Appropriate test categorization with @fast tag.

The @fast tag is correctly applied as these tests can run independently and don't involve complex submission assertions.


226-226: LGTM: Appropriate test categorization with @Sequential tag.

The @sequential tag is correctly applied as this test requires ordered execution of multiple setup steps and involves multiple student submissions and assessments.

Copy link
Contributor

@EneaGore EneaGore left a comment

Choose a reason for hiding this comment

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

Changes make sense to me and it seems faster on average.

@krusche krusche added this to the 7.7.2 milestone Nov 21, 2024
@krusche krusche merged commit 5efb5f4 into develop Nov 21, 2024
32 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants