-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http-client-java, e2e test, use clientcore (#5437)
fix Azure/autorest.java#3000 fix Azure/autorest.java#3002 fix Azure/autorest.java#2986 Cases that generated code cannot compile is currently skipped. Cases that not able to pass is disabled. Current result https://specdashboard.z5.web.core.windows.net/ ![image](https://github.com/user-attachments/assets/d14328b4-be18-4536-90f1-ac07a0046f20) --------- Co-authored-by: hongli750210 <[email protected]>
- Loading branch information
1 parent
27373e7
commit dd36417
Showing
996 changed files
with
105,811 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
packages/http-client-java/generator/http-client-generator-clientcore-test/Generate.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Use case: | ||
# | ||
# The purpose of this script is to compact the steps required to regenerate TypeSpec into a single script. | ||
# | ||
param ( | ||
[int] $Parallelization = [Environment]::ProcessorCount | ||
) | ||
|
||
|
||
$ExitCode = 0 | ||
|
||
if ($Parallelization -lt 1) { | ||
$Parallelization = 1 | ||
} | ||
|
||
Write-Host "Parallelization: $Parallelization" | ||
|
||
|
||
$generateScript = { | ||
$tspFile = $_ | ||
|
||
$tspClientFile = $tspFile -replace 'main.tsp', 'client.tsp' | ||
if (($tspClientFile -match 'client.tsp$') -and (Test-Path $tspClientFile)) { | ||
$tspFile = $tspClientFile | ||
} | ||
|
||
# With TypeSpec code generation being parallelized, we need to make sure that the output directory is unique | ||
# for each test run. We do this by appending a random number to the output directory. | ||
# Without this, we could have multiple runs trying to write to the same directory which introduces race conditions. | ||
$tspOptions = "--option ""@typespec/http-client-java.emitter-output-dir={project-root}/tsp-output/$(Get-Random)""" | ||
if ($tspFile -match "type[\\/]enum[\\/]extensible[\\/]") { | ||
# override namespace for reserved keyword "enum" | ||
$tspOptions += " --option ""@typespec/http-client-java.namespace=type.enums.extensible""" | ||
} elseif ($tspFile -match "type[\\/]enum[\\/]fixed[\\/]") { | ||
# override namespace for reserved keyword "enum" | ||
$tspOptions += " --option ""@typespec/http-client-java.namespace=type.enums.fixed""" | ||
} elseif ($tspFile -match "type[\\/]array" -or $tspFile -match "type[\\/]dictionary") { | ||
# TODO https://github.com/Azure/autorest.java/issues/2964 | ||
# also serve as a test for "use-object-for-unknown" emitter option | ||
$tspOptions += " --option ""@typespec/http-client-java.use-object-for-unknown=true""" | ||
} | ||
|
||
$tspTrace = "--trace import-resolution --trace projection --trace http-client-java" | ||
$tspCommand = "npx --no-install tsp compile $tspFile $tspOptions $tspTrace" | ||
|
||
$timer = [Diagnostics.Stopwatch]::StartNew() | ||
$generateOutput = Invoke-Expression $tspCommand | ||
$timer.Stop() | ||
|
||
$global:ExitCode = $global:ExitCode -bor $LASTEXITCODE | ||
|
||
if ($LASTEXITCODE -ne 0) { | ||
Write-Host " | ||
======================== | ||
$tspCommand | ||
======================== | ||
FAILED (Time elapsed: $($timer.ToString())) | ||
$([String]::Join("`n", $generateOutput)) | ||
" | ||
} else { | ||
Write-Host " | ||
======================== | ||
$tspCommand | ||
======================== | ||
SUCCEEDED (Time elapsed: $($timer.ToString())) | ||
" | ||
} | ||
|
||
if ($global:ExitCode -ne 0) { | ||
exit $global:ExitCode | ||
} | ||
} | ||
|
||
./Setup.ps1 | ||
|
||
if (Test-Path ./src/main) { | ||
Remove-Item ./src/main -Recurse -Force | ||
} | ||
if (Test-Path ./src/samples) { | ||
Remove-Item ./src/samples -Recurse -Force | ||
} | ||
if (Test-Path ./tsp-output) { | ||
Remove-Item ./tsp-output -Recurse -Force | ||
} | ||
|
||
# generate for http-specs/azure-http-specs test sources | ||
Copy-Item -Path node_modules/@typespec/http-specs/specs -Destination ./ -Recurse -Force | ||
# remove xml tests, emitter has not supported xml model | ||
Remove-Item ./specs/payload/xml -Recurse -Force | ||
|
||
# TokenCredential not in core | ||
Remove-Item ./specs/authentication/oauth2 -Recurse -Force | ||
Remove-Item ./specs/authentication/union -Recurse -Force | ||
# Base64Url not in core | ||
Remove-Item ./specs/encode/bytes -Recurse -Force | ||
# DateTimeRfc1123 is private in beta.1, should now be public in main | ||
Remove-Item ./specs/encode/datetime -Recurse -Force | ||
Remove-Item ./specs/special-headers -Recurse -Force | ||
# JacksonAdapter not in core | ||
Remove-Item ./specs/encode/duration -Recurse -Force | ||
|
||
$job = (Get-ChildItem ./specs -Include "main.tsp","old.tsp" -File -Recurse) | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob | ||
|
||
$job | Wait-Job -Timeout 1200 | ||
$job | Receive-Job | ||
|
||
Remove-Item ./specs -Recurse -Force | ||
|
||
Copy-Item -Path ./tsp-output/*/src -Destination ./ -Recurse -Force -Exclude @("module-info.java") | ||
|
||
Remove-Item ./tsp-output -Recurse -Force | ||
|
||
if (Test-Path ./src/main/resources/META-INF/client-structure-service_apiview_properties.json) { | ||
# client structure is generated from multiple client.tsp files and the last one to execute overwrites | ||
# the api view properties file. Because the tests run in parallel, the order is not guaranteed. This | ||
# causes git diff check to fail as the checked in file is not the same as the generated one. | ||
Remove-Item ./src/main/resources/META-INF/client-structure-service_apiview_properties.json -Force | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/http-client-java/generator/http-client-generator-clientcore-test/Setup.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# re-build http-client-java | ||
Set-Location (Resolve-Path (Join-Path $PSScriptRoot '..' '..')) | ||
|
||
./Setup.ps1 | ||
|
||
Set-Location $PSScriptRoot | ||
|
||
npm run clean && npm install |
18 changes: 18 additions & 0 deletions
18
packages/http-client-java/generator/http-client-generator-clientcore-test/Spector-Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#Requires -Version 7.0 | ||
|
||
$ErrorActionPreference = 'Stop' | ||
Set-StrictMode -Version 3.0 | ||
|
||
Write-Host "Running Spector tests" | ||
|
||
Write-Host "Starting the Spector server" | ||
npm run spector-start | ||
Write-Host "Compile and run the tests" | ||
mvn clean test --no-transfer-progress -T 1C | ||
if ($LASTEXITCODE -ne 0) { | ||
exit $LASTEXITCODE | ||
} | ||
Write-Host "Stopping the Spector server" | ||
npm run spector-stop | ||
|
||
Write-Host "Finished running the Spector tests" |
32 changes: 32 additions & 0 deletions
32
packages/http-client-java/generator/http-client-generator-clientcore-test/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@typespec/http-client-java-clientcore-tests", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "rimraf ./node_modules/@typespec/http-client-java ./package-lock.json ./tsp-output", | ||
"format": "npm run -s prettier -- --write", | ||
"check-format": "npm run prettier -- --check", | ||
"prettier": "prettier --config ./.prettierrc.yaml **/*.tsp", | ||
"spector-serve": "tsp-spector serve ./node_modules/@typespec/http-specs/specs --coverageFile ./tsp-spector-coverage-java-standard.json", | ||
"spector-start": "tsp-spector server start ./node_modules/@typespec/http-specs/specs --coverageFile ./tsp-spector-coverage-java-standard.json", | ||
"spector-stop": "tsp-spector server stop" | ||
}, | ||
"dependencies": { | ||
"@typespec/http-specs": "0.1.0-alpha.5", | ||
"@typespec/http-client-java": "file:../../typespec-http-client-java-0.1.5.tgz", | ||
"@typespec/http-client-java-tests": "file:" | ||
}, | ||
"overrides": { | ||
"@typespec/compiler": "~0.63.0", | ||
"@typespec/http": "~0.63.0", | ||
"@typespec/rest": "~0.63.0", | ||
"@typespec/versioning": "~0.63.0", | ||
"@typespec/openapi": "~0.63.0", | ||
"@typespec/xml": "~0.63.0", | ||
"@azure-tools/typespec-azure-core": "~0.49.0", | ||
"@azure-tools/typespec-client-generator-core": "~0.49.1", | ||
"@azure-tools/typespec-azure-resource-manager": "~0.49.0", | ||
"@azure-tools/typespec-autorest": "~0.49.0" | ||
}, | ||
"private": true | ||
} |
77 changes: 77 additions & 0 deletions
77
packages/http-client-java/generator/http-client-generator-clientcore-test/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.microsoft.typespec</groupId> | ||
<artifactId>typespec-java-generator</artifactId> | ||
<version>1.0.0-beta.1</version> | ||
</parent> | ||
|
||
<groupId>com.microsoft.typespec</groupId> | ||
<artifactId>http-client-generator-clientcore-test</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>http-client-generator-test</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<spotless.config.path>../</spotless.config.path> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.clientcore</groupId> | ||
<artifactId>core</artifactId> | ||
<version>1.0.0-beta.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.11.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.projectreactor</groupId> | ||
<artifactId>reactor-test</artifactId> | ||
<version>3.4.41</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<version>4.11.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- bytebuddy dependencies are required for mockito 4.11.0 to work with Java 21. Mockito 4.11.0 is the last release --> | ||
<!-- of Mockito supporting Java 8 as a baseline. --> | ||
<dependency> | ||
<groupId>net.bytebuddy</groupId> | ||
<artifactId>byte-buddy</artifactId> | ||
<version>1.15.5</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.bytebuddy</groupId> | ||
<artifactId>byte-buddy-agent</artifactId> | ||
<version>1.15.5</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<version>1.7.36</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.18.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<version>5.11.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
Oops, something went wrong.