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: Fix running server tests on Windows #9193

Merged
merged 4 commits into from
Aug 8, 2024

Conversation

Strohgelaender
Copy link
Contributor

@Strohgelaender Strohgelaender commented Aug 5, 2024

Checklist

General

Motivation and Context

After #8951 got merged it was no longer possible to run the LocalVC server tests locally. This PR fixes this issue.

Description

This was caused by two issues.

  1. Development: Add support for ephemeral SSH keys for the authentication of build agents #8951 expected the file system to support posix permissions, which is not true on Windows
  2. Integrated code lifecycle: Add option to clone repositories using SSH #8110 was not properly closing the Repository, leading to a failure in the post-test cleanup,

Note: The test testPriorityRunningExam is consistently failing since the merge of PR #8951. This is some issue related to the GitHub-Runners and does not happen locally on any OS. This PR does not fix this issue.

Steps for Testing

run the LocalVCLocalCIIntegrationTest tests locally and see that they pass.

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Summary by CodeRabbit

  • Bug Fixes

    • Improved key loading functionality by filtering out null values, enhancing reliability.
    • Enhanced file permissions handling to be compatible across different operating systems, preventing potential exceptions.
  • Refactor

    • Streamlined resource management in the repository handling, ensuring proper closure and reducing resource leaks.

@Strohgelaender Strohgelaender requested a review from a team as a code owner August 5, 2024 20:02
Copy link

coderabbitai bot commented Aug 5, 2024

Walkthrough

The changes across the Java files enhance the overall robustness and maintainability of key functionalities. Key loading, resource management, and file permission handling have been improved to prevent potential exceptions and ensure compatibility across different operating systems. These modifications employ defensive programming techniques, ensuring that the application behaves predictably in the face of unexpected input or environmental conditions.

Changes

File Path Change Summary
src/main/java/de/tum/in/www1/artemis/config/icl/ssh/... Enhanced key loading by filtering out null entries, improving robustness and readability.
src/main/java/de/tum/in/www1/artemis/config/icl/ssh/... Improved resource management in the run method using try-with-resources for the Repository.
src/main/java/de/tum/in/www1/artemis/service/connectors/... Introduced checks for POSIX file permissions to ensure cross-platform compatibility for private keys.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Application
    participant Repository

    User->>Application: Initiate SSH Command
    Application->>Repository: Open Repository
    alt Successful Operation
        Repository-->>Application: Repository opened
        Application->>User: Command executed successfully
    else Error
        Repository-->>Application: Throw exception
        Application->>User: Handle error
    end
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@github-actions github-actions bot added the server Pull requests that update Java code. (Added Automatically!) label Aug 5, 2024
Copy link
Member

@bensofficial bensofficial left a comment

Choose a reason for hiding this comment

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

Code changes look good to me. Thanks for the fix! 👍

@maximiliansoelch
Copy link
Member

The test testPriorityRunningExam also consistently fails on Bamboo: https://bamboo.ase.in.tum.de/browse/ARTEMIS-TESTS-JAVATEST-6150

@bensofficial Any idea what's causing this?

BBesrour

This comment was marked as resolved.

Copy link
Member

@BBesrour BBesrour left a comment

Choose a reason for hiding this comment

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

Tested locally, tests pass on windows 10, code lgtm

Copy link
Contributor

@pzdr7 pzdr7 left a comment

Choose a reason for hiding this comment

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

The tests pass for me on Windows 10 👍

@bensofficial
Copy link
Member

@maximiliansoelch

The test testPriorityRunningExam also consistently fails on Bamboo: https://bamboo.ase.in.tum.de/browse/ARTEMIS-TESTS-JAVATEST-6150

@bensofficial Any idea what's causing this?

I had a look at the server logs and it seems like the repository does not exist or is not properly created.

build	05-Aug-2024 23:59:08	        21:58:23.459 | 948 git-ssh-thread-1 | DEBUG | .t.i.w.a.s.c.l.LocalVCServletService : Path to resolve repository from: /tmp/SHORTF82F5F4F01E26049980916C09947C03B3EB5TSTEXC/shortf82f5f4f01e26049980916c09947c03b3eb5tstexc-solution.git
build	05-Aug-2024 23:59:08	        21:58:23.459 | 948 git-ssh-thread-1 | ERROR | .t.i.w.a.s.c.l.LocalVCServletService : Could not find local repository with name SHORTF82F5F4F01E26049980916C09947C03B3EB5TSTEXC/shortf82f5f4f01e26049980916c09947c03b3eb5tstexc-solution.git

The build agent tries to clone the repository, but apparently the server cannot find the folder of the repository.

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.

code

@Strohgelaender Strohgelaender added this to the 7.5.0 milestone Aug 8, 2024
@krusche krusche merged commit 8ed72b1 into develop Aug 8, 2024
29 of 34 checks passed
@krusche krusche deleted the chore/ssh-tests-windows branch August 8, 2024 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge server Pull requests that update Java code. (Added Automatically!)
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants