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

[@azure-tools/cadl-ranch-specs] - Add Scenarios for Server Tests and Testing Framework #729

Closed
wants to merge 17 commits into from

Conversation

sarangan12
Copy link
Member

@sarangan12 sarangan12 commented Sep 22, 2024

This PR adds the server-test scenarios along with the framework to test those scenarios.

In order to test the new server-test scenarios, there are 3 modes enabled:

  1. Specify the name of one scenario in the command line.
  2. Specify the list of scenarios to be tested in a file and provide this file as input in the command line
  3. If the above modes are not specified, then the framework will execute all the scenarios.

Mode 1 - One Scenario in Command Line

Screenshot 2024-09-23 095806

Mode 2 - Multiple Scenarios in file

Screenshot 2024-09-23 100006

Mode 3 - All Scenarios
Screenshot 2024-09-23 100310

Screenshot 2024-09-23 100614

This PR is equivalent of the PR microsoft/typespec#4516. Except for some cosmetic changes in imports, etc, the code changes are same. I am doing the changes in both to ensure both are in sync.

Copy link

changeset-bot bot commented Sep 22, 2024

🦋 Changeset detected

Latest commit: 897ff94

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@azure-tools/cadl-ranch-specs Minor
@azure-tools/cadl-ranch-api Minor
@azure-tools/cadl-ranch Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@timotheeguerin timotheeguerin left a comment

Choose a reason for hiding this comment

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

Shouldn't that PR be in the typespec repo?

@sarangan12
Copy link
Member Author

@timotheeguerin The original plan is to make the changes here and then port this package completely to the typespec repository. Do you agree? Do you want the changes only in Typespec repo i.e. migrate the cadl-ranch-specs repository with the new code changes in this PR? Please let me know.

@timotheeguerin
Copy link
Member

sure as long as the change you make here are completely back compatible

@sarangan12
Copy link
Member Author

sure as long as the change you make here are completely back compatible

They are backward compatible. None of the existing scenarios will be affected

@sarangan12 sarangan12 changed the title Service test [@azure-tools/cadl-ranch-specs] - Add Scenarios for Server Tests and Testing Framework Sep 24, 2024
@sarangan12 sarangan12 marked this pull request as ready for review September 24, 2024 18:56
return `${this.getImportContents()}\n${this.getGlobalDeclarationContents()}\n${this.getDescribeContents()}`;
}

public async generateFile() {
Copy link
Member

Choose a reason for hiding this comment

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

This feels very weird to resort to that, why not directly run things, this is going to make debugging impossible.
I don't feel like there is much point running vitest as well on top or any other test runner. We won't use the language for the test runner

Copy link
Member Author

Choose a reason for hiding this comment

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

@timotheeguerin This actually generates the spec files that could be run using the vitest. Any errors could be seen directly in the generated spec files. So, the debugging should be simple enough. Dont you think?

Copy link
Member

Choose a reason for hiding this comment

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

this just feels like a lot of pain to maintain regardless, now if we need to add some more complex scenario you don't need to just make the call yourself you need to reserialize that code to a file(the whole request creation that is currently hardcoded in that file).
What is the benefit of using a test runner here? I think it would be much better to just have the cli and if having vitest IDE support is important then you call to vitest api directly without shelkling a new process and writing new files.

github-merge-queue bot pushed a commit to microsoft/typespec that referenced this pull request Sep 30, 2024
… repository with server tests and framework (#4516)

This PR has the following changes:

1. Migrates the `cadl-ranch-specs ` package from the `cadl-ranch`
repository to this `typespec` repository.
2. Adds the server-test scenarios along with the framework to test those
scenarios.

In order to test the new server-test scenarios, there are 3 modes
enabled:

1. Specify the name of one scenario in the command line.
2. Specify the list of scenarios to be tested in a file and provide this
file as input in the command line
3. If the above modes are not specified, then the framework will execute
all the scenarios.

**Mode 1 - One Scenario in Command Line**

![Screenshot 2024-09-23
150451](https://github.com/user-attachments/assets/cd43c07c-1b37-4d5c-bd33-02c59e3539d1)

**Mode 2 - Multiple Scenarios in file** 

![Screenshot 2024-09-23
150615](https://github.com/user-attachments/assets/7b6be4f3-566d-48f4-bd36-cbbb91078339)

**Mode 3 - All Scenarios**

![Screenshot 2024-09-23
150636](https://github.com/user-attachments/assets/40263bf8-2cbb-4e4c-85ea-f1af634c6f42)

![Screenshot 2024-09-23
150749](https://github.com/user-attachments/assets/0d7fd055-de13-42f4-a4d6-85b837fec1e9)

This PR is equivalent of the PR
Azure/cadl-ranch#729. Except for some cosmetic
changes in imports, etc, the code changes are same. I am doing the
changes in both to ensure both are in sync.
@sarangan12
Copy link
Member Author

This PR is no longer required. Closing it

@sarangan12 sarangan12 closed this Oct 4, 2024
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.

2 participants