[testmodeler] load apiscenario 1.2 with oav@3.0 (#3613)

* read operationId

* install oav@3.0.3

* add test.md

* remove localcheck

* fix

* changelog

* configurable loader option

* changelog

* lint

* fixcg

* publish

* Revert "publish"

This reverts commit 8f1b13b99a.

* --testmodeler.export-explicit-type

* publish
This commit is contained in:
changlong-liu 2022-07-21 15:28:22 +08:00 коммит произвёл GitHub
Родитель 59927be6c1
Коммит 681da8a923
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
24 изменённых файлов: 91971 добавлений и 15672 удалений

Просмотреть файл

@ -107,3 +107,6 @@ lib
# Project
**/test/**/*.yaml
**/test/**/*.json
# api scenario files
*.yaml

Просмотреть файл

@ -1,10 +0,0 @@
{
"changes": [
{
"packageName": "@autorest/testmodeler",
"comment": "Use modelerfour@4.23.7 and add securityParameters in ExampleModel for ApiKey securityDefinitions.",
"type": "minor"
}
],
"packageName": "@autorest/testmodeler"
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,6 +1,27 @@
{
"name": "@autorest/testmodeler",
"entries": [
{
"version": "2.3.0",
"tag": "@autorest/testmodeler_v2.3.0",
"date": "Thu, 21 Jul 2022 06:46:35 GMT",
"comments": {
"minor": [
{
"comment": "Use modelerfour@4.23.7 and add securityParameters in ExampleModel for ApiKey securityDefinitions."
},
{
"comment": "use apiscenario 1.2 via oav@3.0.3"
},
{
"comment": "add --testmodeler.api-scenario-loader-option to make api scenario loader configurable"
},
{
"comment": "Add --testmodeler.export-explicit-type to support explicit types in exported codemodel."
}
]
}
},
{
"version": "2.2.5",
"tag": "@autorest/testmodeler_v2.2.5",

Просмотреть файл

@ -1,6 +1,16 @@
# Change Log - @autorest/testmodeler
This log was last generated on Sun, 24 Apr 2022 09:41:30 GMT and should not be manually modified.
This log was last generated on Thu, 21 Jul 2022 06:46:35 GMT and should not be manually modified.
## 2.3.0
Thu, 21 Jul 2022 06:46:35 GMT
### Minor changes
- Use modelerfour@4.23.7 and add securityParameters in ExampleModel for ApiKey securityDefinitions.
- use apiscenario 1.2 via oav@3.0.3
- add --testmodeler.api-scenario-loader-option to make api scenario loader configurable
- Add --testmodeler.export-explicit-type to support explicit types in exported codemodel.
## 2.2.5
Sun, 24 Apr 2022 09:41:30 GMT

Просмотреть файл

@ -67,7 +67,7 @@ The default value of this option is true.
### --testmodeler.use-example-model
This options switch whether ExampleModel in generated in test model. While default to be true, it can be disabled like below:
This option switch whether ExampleModel in generated in test model. While default to be true, it can be disabled like below:
```
testmodeler:
use-example-model: false
@ -75,12 +75,45 @@ testmodeler:
### --testmodeler.add-armtemplate-payload-string
This options switch whether StepArmTemplateModel.armTemplatePayloadString is added into testmodeler. While default to be false, it can be enabled like below:
This option switch whether StepArmTemplateModel.armTemplatePayloadString is added into testmodeler. While default to be false, it can be enabled like below:
```
testmodeler:
add-armtemplate-payload-string: true
```
### --testmodeler.api-scenario-loader-option
The api-scenarios are loaded from the autorest input-files by default. This option provide a gate to load api-scenario from other remote/branch/commit.
This option are passed through directly to oav scenario loader, refer to https://github.com/Azure/oav/blob/develop/lib/apiScenario/apiScenarioLoader.ts#L60 for more detail of it. A sample for this option:
```
testmodeler:
api-scenario-loader-option:
fileRoot: https://github.com/Azure/azure-rest-api-specs/blob/eb829ed4739fccb03dd2327b7762392e74c80ae4/specification/appplatform/resource-manager
swaggerFilePaths:
- 'Microsoft.AppPlatform/preview/2020-11-01-preview/appplatform.json'
```
### --test-resources
The list of api-scenarios want to get loaded into testmodeler. Below is a sample:
```
test-resources:
- test: Microsoft.AppPlatform/preview/2020-11-01-preview/scenarios/Spring.yaml
```
### --testmodeler.export-explicit-type
Whether to export codemodel with tags on primitive types, default as false. Demonstrate on the output values:
```
// with primitive types:
isDataAction: !!bool false
count: !!int 64
// with no types:
isDataAction: false
count: 64
```
## Autorest Pipeline Configurations

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "@autorest/testmodeler",
"version": "2.2.5",
"version": "2.3.0",
"description": "Autorest extension for testmodeler",
"main": "dist/index.js",
"scripts": {
@ -54,8 +54,9 @@
"jsonpath": "^1.1.1",
"lodash": "~4.17.21",
"node-yaml": "^3.2.0",
"oav": "2.12.1",
"reflect-metadata": "~0.1.13"
"oav": "3.0.3",
"reflect-metadata": "~0.1.13",
"yuml2svg": "^5.0.1"
},
"files": [
"dist/src",

Просмотреть файл

@ -12,6 +12,8 @@ export enum Config {
scenarioCodeModelRestCallOnly = 'testmodeler.scenario.codemodel-restcall-only',
useExampleModel = 'testmodeler.use-example-model',
addArmTemplatePayloadString = 'testmodeler.add-armtemplate-payload-string',
apiScenarioLoaderOption = 'testmodeler.api-scenario-loader-option',
exportExplicitType = 'testmodeler.export-explicit-type',
}
export const configDefaults = {
@ -23,6 +25,7 @@ export const configDefaults = {
[Config.scenarioCodeModelRestCallOnly]: true,
[Config.useExampleModel]: true,
[Config.addArmTemplatePayloadString]: false,
[Config.exportExplicitType]: false,
};
export enum TestScenarioVariableNames {

Просмотреть файл

@ -30,8 +30,8 @@ export enum ExtensionName {
xMsExamples = 'x-ms-examples',
}
export interface ExampleExtensionResponse {
body: any;
headers: Record<string, any>;
body?: any;
headers?: Record<string, any>;
}
export interface ExampleExtension {
parameters?: Record<string, any>;
@ -370,7 +370,7 @@ export class TestCodeModeler {
}
this.codeModel.operationGroups.forEach((operationGroup) => {
operationGroup.operations.forEach((operation) => {
const operationId = operationGroup.language.default.name + '_' + operation.language.default.name;
const operationId = operation.operationId ? operation.operationId : operationGroup.language.default.name + '_' + operation.language.default.name;
// TODO: skip non-json http bodys for now. Need to validate example type with body schema to support it.
const mediaTypes = operation.requests[0]?.protocol?.http?.mediaTypes;
if (mediaTypes && mediaTypes.indexOf('application/json') < 0) {
@ -471,15 +471,10 @@ export class TestCodeModeler {
step.exampleModel = this.createExampleModel(
session,
{
parameters: step.requestParameters,
responses: {
[step.statusCode]: {
body: step.expectedResponse,
headers: {},
},
},
parameters: step.parameters,
responses: step.responses,
},
step.exampleName,
step.exampleFile,
operation,
operationGroup,
);
@ -578,7 +573,7 @@ export class TestCodeModeler {
const stepModel = step as StepRestCallModel;
this.initiateRestCall(session, stepModel);
if (codeModelRestcallOnly && !stepModel.exampleModel) {
throw new Error(`Can't find operationId ${step.operationId}[step ${step.exampleName}] in codeModel!`);
throw new Error(`Can't find operationId ${step.operationId}[step ${step.step}] in codeModel!`);
}
} else if (step.type === OavStepType.armTemplate) {
testDef.useArmTemplate = true;
@ -599,24 +594,26 @@ export class TestCodeModeler {
}
}
public createApiScenarioLoaderOption(fileRoot: string) {
const options = {
useJsonParser: false,
checkUnderFileRoot: false,
fileRoot: fileRoot,
swaggerFilePaths: this.testConfig.getValue(Config.inputFile),
eraseXmsExamples: false,
};
return { ...options, ...this.testConfig.getValue(Config.apiScenarioLoaderOption, {}) };
}
public async loadTestResourcesFromConfig(session: Session<TestCodeModel>, fileRoot: string) {
for (const testResource of this.testConfig.getValue(Config.testResources)) {
if (fs.existsSync(path.join(fileRoot, testResource[Config.test]))) {
try {
const loader = ApiScenarioLoader.create({
useJsonParser: false,
checkUnderFileRoot: false,
fileRoot: fileRoot,
swaggerFilePaths: this.testConfig.getValue(Config.inputFile),
});
const testDef = (await loader.load(testResource[Config.test])) as TestDefinitionModel;
this.initiateTestDefinition(session, testDef);
this.codeModel.testModel.scenarioTests.push(testDef);
} catch (error) {
session.warning(`Exception occured when load testdef ${testResource[Config.test]}: ${error}`, ['Test Modeler']);
}
} else {
session.warning(`Unexisted test resource scenario file: ${testResource[Config.test]}`, ['Test Modeler']);
try {
const loader = ApiScenarioLoader.create(this.createApiScenarioLoaderOption(fileRoot));
const testDef = (await loader.load(testResource[Config.test])) as TestDefinitionModel;
this.initiateTestDefinition(session, testDef);
this.codeModel.testModel.scenarioTests.push(testDef);
} catch (error) {
session.warning(`Exception occured when load testdef ${testResource[Config.test]}: ${error}`, ['Test Modeler']);
}
}
}
@ -633,14 +630,10 @@ export class TestCodeModeler {
if (!scenarioFile.endsWith('.yaml') && !scenarioFile.endsWith('.yml')) {
continue;
}
const scenarioPathName = path.join(apiFolder, scenariosFolder, scenarioFile);
let scenarioPathName = path.join(apiFolder, scenariosFolder, scenarioFile);
try {
const loader = ApiScenarioLoader.create({
useJsonParser: false,
checkUnderFileRoot: false,
fileRoot: fileRoot,
swaggerFilePaths: this.testConfig.getValue(Config.inputFile),
});
const loader = ApiScenarioLoader.create(this.createApiScenarioLoaderOption(fileRoot));
scenarioPathName = scenarioPathName.split('\\').join('/');
const testDef = (await loader.load(scenarioPathName)) as TestDefinitionModel;
this.initiateTestDefinition(session, testDef, codemodelRestCallOnly);

Просмотреть файл

@ -16,7 +16,7 @@ export async function processRequest(host: AutorestExtensionHost): Promise<void>
const config = new TestConfig(await session.getValue(''), configDefaults);
if (config.getValue(Config.exportCodemodel)) {
Helper.addCodeModelDump(session, 'test-modeler-pre.yaml');
Helper.addCodeModelDump(session, 'test-modeler-pre.yaml', false);
}
// const files = await session.listInputs()
// const codemodel = await session.readFile('code-model-v4.yaml')
@ -25,9 +25,12 @@ export async function processRequest(host: AutorestExtensionHost): Promise<void>
codeModel.genMockTests(session);
await codeModel.loadTestResources(session);
await Helper.outputToModelerfour(host, session);
await Helper.outputToModelerfour(host, session, config.getValue(Config.exportExplicitType));
if (config.getValue(Config.exportCodemodel)) {
Helper.addCodeModelDump(session, 'test-modeler.yaml');
Helper.addCodeModelDump(session, 'test-modeler.yaml', false);
if (config.getValue(Config.exportExplicitType)) {
Helper.addCodeModelDump(session, 'test-modeler-with-tags.yaml', true);
}
}
await Helper.dump(host);
}

Просмотреть файл

@ -8,12 +8,18 @@ import { comment, serialize } from '@azure-tools/codegen';
export class Helper {
static dumpBuf: Record<string, any> = {};
public static async outputToModelerfour(host: AutorestExtensionHost, session: Session<CodeModel>): Promise<void> {
public static async outputToModelerfour(host: AutorestExtensionHost, session: Session<CodeModel>, exportExplicitTypes: boolean): Promise<void> {
// write the final result first which is hardcoded in the Session class to use to build the model..
// overwrite the modelerfour which should be fine considering our change is backward compatible
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const modelerfourOptions = await session.getValue('modelerfour', {});
if (modelerfourOptions['emit-yaml-tags'] !== false) {
if (exportExplicitTypes) {
codeModelSchema.explicit = (codeModelSchema.explicit || []).concat(codeModelSchema.implicit);
codeModelSchema.implicit = [];
codeModelSchema.compiledExplicit = (codeModelSchema.compiledExplicit || []).concat(codeModelSchema.compiledImplicit);
codeModelSchema.compiledImplicit = [];
}
host.writeFile({
filename: 'code-model-v4.yaml',
content: serialize(session.model, { schema: codeModelSchema }),
@ -29,8 +35,8 @@ export class Helper {
}
}
public static addCodeModelDump(session: Session<CodeModel>, fileName: string, debugOnly = true) {
this.dumpBuf[(debugOnly ? '__debug/' : '') + fileName] = serialize(session.model);
public static addCodeModelDump(session: Session<CodeModel>, fileName: string, withTags: boolean, debugOnly = true) {
this.dumpBuf[(debugOnly ? '__debug/' : '') + fileName] = withTags ? serialize(session.model, { schema: codeModelSchema }) : serialize(session.model);
}
public static async dump(host: AutorestExtensionHost): Promise<void> {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -11960,12 +11960,12 @@ operationGroups:
artifactSelector: sub-module-1
relativePath: resources/a172cedcae47474b615c54d510a5d84a8dea3032e958587430b413538be3f333-2019082605-e3095339-1723-44b7-8b5e-31b1003978bc
version: '1.0'
sku:
name: S0
capacity: 1
tier: Standard
resourceGroupName: myResourceGroup
serviceName: myservice
sku:
name: S0
capacity: 1
tier: Standard
subscriptionId: 00000000-0000-0000-0000-000000000000
responses:
'200':

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -150968,16 +150968,24 @@ testModel:
operation: *ref_4319
operationGroup: *ref_4289
scenarioTests:
- &ref_4328
- &ref_4323
_filePath: Microsoft.Compute\stable\2021-03-01\test-scenarios\sample.yaml
_swaggerFilePaths:
- Microsoft.Compute/stable/2021-03-01/compute.json
- Microsoft.Compute/stable/2021-03-01/runCommands.json
- Microsoft.Compute/stable/2019-04-01/skus.json
- Microsoft.Compute/stable/2020-12-01/disk.json
- Microsoft.Compute/stable/2020-09-30/gallery.json
- Microsoft.Compute/stable/2020-09-30/sharedGallery.json
- Microsoft.Compute/stable/2021-03-01/cloudService.json
cleanUpSteps: []
prepareSteps:
- &ref_4323
type: restCall
- type: restCall
operationId: ProximityPlacementGroups_Delete
description: Create a proximity placement group.
exampleFile: ../examples/DeleteAProximityPlacementGroup.json
exampleModel:
name: Create a proximity placement group.
name: ../examples/DeleteAProximityPlacementGroup.json
clientParameters:
- exampleValue:
schema: *ref_1325
@ -151008,27 +151016,23 @@ testModel:
body:
rawValue: &ref_4321 {}
language: *ref_4320
headers: {}
exampleName: Create a proximity placement group.
expectedResponse: *ref_4321
isPrepareStep: true
outputVariables: {}
outputVariablesModel: {}
requestParameters:
parameters:
api-version: '2021-03-01'
parameters: {}
proximityPlacementGroupName: $(resourceName)
resourceGroupName: $(resourceGroupName)
subscriptionId: $(subscriptionId)
requestUpdate: []
requiredVariables: []
requiredVariablesDefault: {}
resourceUpdate: []
responseUpdate: []
secretVariables: []
statusCode: 200
step: Delete-proximity-placement-group
variables: {}
responses:
'200':
body: *ref_4321
requiredVariables:
- subscriptionId
- location
@ -151038,10 +151042,18 @@ testModel:
subscriptionId: 00000000-00000000-00000000-00000000
scenarios:
- description: Microsoft.SignalRService/Basic_CRUD
_resolvedSteps:
- *ref_4323
- &ref_4324
type: armTemplateDeployment
_scenarioDef: *ref_4323
requiredVariables:
- subscriptionId
- location
requiredVariablesDefault:
location: westus
subscriptionId: 00000000-00000000-00000000-00000000
scenario: scenario_0
secretVariables: []
shareScope: true
steps:
- type: armTemplateDeployment
armTemplate: ./peArmTemplate/Generate_Unique_name_template.json
armTemplatePayload:
$schema: https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#
@ -151066,12 +151078,12 @@ testModel:
secretVariables: []
step: Generate_Unique_Name
variables: {}
- &ref_4325
type: restCall
- type: restCall
operationId: ProximityPlacementGroups_CreateOrUpdate
description: Create or Update a proximity placement group.
exampleFile: ../examples/CreateOrUpdateAProximityPlacementGroup.json
exampleModel:
name: Create or Update a proximity placement group.
name: ../examples/CreateOrUpdateAProximityPlacementGroup.json
clientParameters:
- exampleValue:
schema: *ref_1325
@ -151158,24 +151170,50 @@ testModel:
language: *ref_2268
language: *ref_2267
language: *ref_2269
headers: {}
exampleName: Create or Update a proximity placement group.
expectedResponse:
name: myProximityPlacementGroup
type: Microsoft.Compute/proximityPlacementGroups
id: /subscriptions/$(subscriptionId)/resourceGroups/$(resourceGroupName)/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup
location: westus
properties:
proximityPlacementGroupType: Standard
'201':
body:
schema: *ref_566
parentsValue:
Resource:
schema: *ref_18
parentsValue: {}
properties:
name:
schema: *ref_588
rawValue: myProximityPlacementGroup
language: *ref_2244
type:
schema: *ref_589
rawValue: Microsoft.Compute/proximityPlacementGroups
language: *ref_2245
id:
schema: *ref_587
rawValue: /subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup
language: *ref_2243
location:
schema: *ref_590
rawValue: westus
language: *ref_2238
language: *ref_2237
properties:
properties:
schema: *ref_639
parentsValue: {}
properties:
proximityPlacementGroupType:
schema: *ref_19
rawValue: Standard
language: *ref_2268
language: *ref_2267
language: *ref_2270
outputVariables:
fakeScenarioVar:
type: string
fromResponse: /id
outputVariablesModel:
fakeScenarioVar:
- type: object
languages: *ref_2243
requestParameters:
parameters:
api-version: '2021-03-01'
parameters:
location: $(location)
@ -151184,21 +151222,34 @@ testModel:
proximityPlacementGroupName: $(resourceName)
resourceGroupName: $(resourceGroupName)
subscriptionId: $(subscriptionId)
requestUpdate: []
requiredVariables: []
requiredVariablesDefault: {}
resourceUpdate: []
responseUpdate: []
secretVariables: []
statusCode: 200
step: Create-or-Update-a-proximity-placement-group
variables: {}
- &ref_4326
type: restCall
responses:
'200':
body:
name: myProximityPlacementGroup
type: Microsoft.Compute/proximityPlacementGroups
id: /subscriptions/$(subscriptionId)/resourceGroups/$(resourceGroupName)/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup
location: westus
properties:
proximityPlacementGroupType: Standard
'201':
body:
name: myProximityPlacementGroup
type: Microsoft.Compute/proximityPlacementGroups
id: /subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myProximityPlacementGroup
location: westus
properties:
proximityPlacementGroupType: Standard
- type: restCall
operationId: ProximityPlacementGroups_Delete
description: Create a proximity placement group.
exampleFile: ../examples/DeleteAProximityPlacementGroup.json
exampleModel:
name: Create a proximity placement group.
name: ../examples/DeleteAProximityPlacementGroup.json
clientParameters:
- exampleValue:
schema: *ref_1325
@ -151229,32 +151280,28 @@ testModel:
body:
rawValue: &ref_4322 {}
language: *ref_4320
headers: {}
exampleName: Create a proximity placement group.
expectedResponse: *ref_4322
outputVariables: {}
outputVariablesModel: {}
requestParameters:
parameters:
api-version: '2021-03-01'
parameters: {}
proximityPlacementGroupName: $(resourceName)
resourceGroupName: $(resourceGroupName)
subscriptionId: $(subscriptionId)
requestUpdate: []
requiredVariables: []
requiredVariablesDefault: {}
resourceUpdate: []
responseUpdate: []
secretVariables: []
statusCode: 200
step: Delete-proximity_placement_group
variables: {}
- &ref_4327
type: restCall
responses:
'200':
body: *ref_4322
- type: restCall
operationId: VirtualMachines_CreateOrUpdate
description: Create a vm with Host Encryption using encryptionAtHost property.
exampleFile: ../examples/CreateAVmWithEncryptionAtHost.json
exampleModel:
name: Create a vm with Host Encryption using encryptionAtHost property.
name: ../examples/CreateAVmWithEncryptionAtHost.json
clientParameters:
- exampleValue:
schema: *ref_1325
@ -151630,53 +151677,204 @@ testModel:
language: *ref_2465
language: *ref_2435
language: *ref_2483
headers: {}
exampleName: Create a vm with Host Encryption using encryptionAtHost property.
expectedResponse:
name: myVM
type: Microsoft.Compute/virtualMachines
id: /subscriptions/$(subscriptionId)/resourceGroups/$(resourceGroupName)/providers/Microsoft.Compute/virtualMachines/myVM
location: westus
plan:
name: standard-data-science-vm
product: standard-data-science-vm
publisher: microsoft-ads
properties:
hardwareProfile:
vmSize: Standard_DS1_v2
networkProfile:
networkInterfaces:
- id: /subscriptions/$(subscriptionId)/resourceGroups/$(resourceGroupName)/providers/Microsoft.Network/networkInterfaces/nsgExistingNic
'201':
body:
schema: *ref_571
parentsValue:
Resource:
schema: *ref_18
parentsValue: {}
properties:
name:
schema: *ref_588
rawValue: myVM
language: *ref_2244
type:
schema: *ref_589
rawValue: Microsoft.Compute/virtualMachines
language: *ref_2245
id:
schema: *ref_587
rawValue: /subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM
language: *ref_2243
location:
schema: *ref_590
rawValue: westus
language: *ref_2238
language: *ref_2237
properties:
plan:
schema: *ref_286
parentsValue: {}
properties:
name:
schema: *ref_150
rawValue: standard-data-science-vm
language: *ref_2532
product:
schema: *ref_152
rawValue: standard-data-science-vm
language: *ref_2534
publisher:
schema: *ref_151
rawValue: microsoft-ads
language: *ref_2533
language: *ref_2531
properties:
primary: true
osProfile:
adminUsername: '{your-username}'
computerName: myVM
secrets: []
windowsConfiguration:
enableAutomaticUpdates: true
provisionVMAgent: true
provisioningState: Creating
securityProfile:
encryptionAtHost: true
storageProfile:
dataDisks: []
imageReference:
offer: standard-data-science-vm
publisher: microsoft-ads
sku: standard-data-science-vm
version: latest
osDisk:
name: myVMosdisk
caching: ReadOnly
createOption: FromImage
managedDisk:
storageAccountType: Standard_LRS
osType: Windows
vmId: 5c0d55a7-c407-4ed6-bf7d-ddb810267c85
schema: *ref_604
parentsValue: {}
properties:
hardwareProfile:
schema: *ref_354
parentsValue: {}
properties:
vmSize:
schema: *ref_154
rawValue: Standard_DS1_v2
language: *ref_2437
language: *ref_2436
networkProfile:
schema: *ref_393
parentsValue: {}
properties:
networkInterfaces:
schema: *ref_1165
elements:
- schema: *ref_79
parentsValue:
SubResource:
schema: *ref_22
parentsValue: {}
properties:
id:
schema: *ref_83
rawValue: /subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/nsgExistingNic
language: *ref_2257
language: *ref_2293
properties:
properties:
schema: *ref_681
parentsValue: {}
properties:
primary:
schema: *ref_46
rawValue: true
language: *ref_2482
language: *ref_2481
language: *ref_2462
language: *ref_2461
osProfile:
schema: *ref_361
parentsValue: {}
properties:
adminUsername:
schema: *ref_177
rawValue: '{your-username}'
language: *ref_2455
computerName:
schema: *ref_176
rawValue: myVM
language: *ref_2454
secrets:
schema: *ref_1164
elements: []
language: *ref_2459
windowsConfiguration:
schema: *ref_302
parentsValue: {}
properties:
enableAutomaticUpdates:
schema: *ref_181
rawValue: true
language: *ref_2458
provisionVMAgent:
schema: *ref_180
rawValue: true
language: *ref_2457
language: *ref_2456
language: *ref_2453
provisioningState:
schema: *ref_222
rawValue: Creating
language: *ref_2464
securityProfile:
schema: *ref_315
parentsValue: {}
properties:
encryptionAtHost:
schema: *ref_215
rawValue: true
language: *ref_2535
language: *ref_2487
storageProfile:
schema: *ref_392
parentsValue: {}
properties:
dataDisks:
schema: *ref_1159
elements: []
language: *ref_2452
imageReference:
schema: *ref_77
parentsValue: {}
properties:
offer:
schema: *ref_40
rawValue: standard-data-science-vm
language: *ref_2441
publisher:
schema: *ref_39
rawValue: microsoft-ads
language: *ref_2440
sku:
schema: *ref_41
rawValue: standard-data-science-vm
language: *ref_2442
version:
schema: *ref_42
rawValue: latest
language: *ref_2443
language: *ref_2439
osDisk:
schema: *ref_669
parentsValue: {}
properties:
name:
schema: *ref_158
rawValue: myVMosdisk
language: *ref_2446
caching:
schema: *ref_161
rawValue: ReadOnly
language: *ref_2449
createOption:
schema: *ref_165
rawValue: FromImage
language: *ref_2450
managedDisk:
schema: *ref_78
parentsValue: {}
properties:
storageAccountType:
schema: *ref_44
rawValue: Standard_LRS
language: *ref_2475
language: *ref_2474
osType:
schema: *ref_26
rawValue: Windows
language: *ref_2445
language: *ref_2444
language: *ref_2438
vmId:
schema: *ref_272
rawValue: 5c0d55a7-c407-4ed6-bf7d-ddb810267c85
language: *ref_2465
language: *ref_2435
language: *ref_2484
outputVariables: {}
outputVariablesModel: {}
requestParameters:
parameters:
api-version: '2021-03-01'
parameters:
location: $(location)
@ -151713,43 +151911,127 @@ testModel:
resourceGroupName: $(resourceGroupName)
subscriptionId: $(subscriptionId)
vmName: myVM
requestUpdate: []
requiredVariables: []
requiredVariablesDefault: {}
resourceUpdate: []
responseUpdate: []
secretVariables: []
statusCode: 200
step: Create_a_vm_with_Host_Encryption_using_encryptionAtHost_property
variables:
fakeStepVar: signalrswaggertest6
_scenarioDef: *ref_4328
fakeStepVar:
type: string
value: signalrswaggertest6
responses:
'200':
body:
name: myVM
type: Microsoft.Compute/virtualMachines
id: /subscriptions/$(subscriptionId)/resourceGroups/$(resourceGroupName)/providers/Microsoft.Compute/virtualMachines/myVM
location: westus
plan:
name: standard-data-science-vm
product: standard-data-science-vm
publisher: microsoft-ads
properties:
hardwareProfile:
vmSize: Standard_DS1_v2
networkProfile:
networkInterfaces:
- id: /subscriptions/$(subscriptionId)/resourceGroups/$(resourceGroupName)/providers/Microsoft.Network/networkInterfaces/nsgExistingNic
properties:
primary: true
osProfile:
adminUsername: '{your-username}'
computerName: myVM
secrets: []
windowsConfiguration:
enableAutomaticUpdates: true
provisionVMAgent: true
provisioningState: Creating
securityProfile:
encryptionAtHost: true
storageProfile:
dataDisks: []
imageReference:
offer: standard-data-science-vm
publisher: microsoft-ads
sku: standard-data-science-vm
version: latest
osDisk:
name: myVMosdisk
caching: ReadOnly
createOption: FromImage
managedDisk:
storageAccountType: Standard_LRS
osType: Windows
vmId: 5c0d55a7-c407-4ed6-bf7d-ddb810267c85
'201':
body:
name: myVM
type: Microsoft.Compute/virtualMachines
id: /subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM
location: westus
plan:
name: standard-data-science-vm
product: standard-data-science-vm
publisher: microsoft-ads
properties:
hardwareProfile:
vmSize: Standard_DS1_v2
networkProfile:
networkInterfaces:
- id: /subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/nsgExistingNic
properties:
primary: true
osProfile:
adminUsername: '{your-username}'
computerName: myVM
secrets: []
windowsConfiguration:
enableAutomaticUpdates: true
provisionVMAgent: true
provisioningState: Creating
securityProfile:
encryptionAtHost: true
storageProfile:
dataDisks: []
imageReference:
offer: standard-data-science-vm
publisher: microsoft-ads
sku: standard-data-science-vm
version: latest
osDisk:
name: myVMosdisk
caching: ReadOnly
createOption: FromImage
managedDisk:
storageAccountType: Standard_LRS
osType: Windows
vmId: 5c0d55a7-c407-4ed6-bf7d-ddb810267c85
variables:
name:
type: string
fakeScenarioVar:
type: string
value: signalrswaggertest5
resourceName:
type: string
- description: Microsoft.SignalRService/DeleteOnly
_scenarioDef: *ref_4323
requiredVariables:
- subscriptionId
- location
requiredVariablesDefault:
location: westus
subscriptionId: 00000000-00000000-00000000-00000000
scenario: scenario_1
secretVariables: []
shareScope: true
steps:
- *ref_4324
- *ref_4325
- *ref_4326
- *ref_4327
variables:
name: $(name)
fakeScenarioVar: signalrswaggertest5
resourceName: $(resourceName)
- description: Microsoft.SignalRService/DeleteOnly
_resolvedSteps:
- *ref_4323
- &ref_4330
type: restCall
- type: restCall
operationId: ProximityPlacementGroups_Delete
description: Create a proximity placement group.
exampleFile: ../examples/DeleteAProximityPlacementGroup.json
exampleModel:
name: Create a proximity placement group.
name: ../examples/DeleteAProximityPlacementGroup.json
clientParameters:
- exampleValue:
schema: *ref_1325
@ -151778,46 +152060,35 @@ testModel:
responses:
'200':
body:
rawValue: &ref_4329 {}
rawValue: &ref_4324 {}
language: *ref_4320
headers: {}
exampleName: Create a proximity placement group.
expectedResponse: *ref_4329
outputVariables: {}
outputVariablesModel: {}
requestParameters:
parameters:
api-version: '2021-03-01'
parameters: {}
proximityPlacementGroupName: $(resourceName)
resourceGroupName: $(resourceGroupName)
subscriptionId: $(subscriptionId)
requestUpdate: []
requiredVariables: []
requiredVariablesDefault: {}
resourceUpdate: []
responseUpdate: []
secretVariables: []
statusCode: 200
step: Delete_proximity_placement_group
variables: {}
_scenarioDef: *ref_4328
requiredVariables:
- subscriptionId
- location
requiredVariablesDefault:
location: westus
subscriptionId: 00000000-00000000-00000000-00000000
secretVariables: []
shareScope: true
steps:
- *ref_4330
responses:
'200':
body: *ref_4324
variables: {}
scope: ResourceGroup
secretVariables: []
useArmTemplate: true
variables:
fakeStepVar: signalrswaggertest4
resourceName: signalrswaggertest4
fakeStepVar:
type: string
value: signalrswaggertest4
resourceName:
type: string
value: signalrswaggertest4
language:
default:
name: ComputeManagementClient

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -99,7 +99,7 @@ describe('Run autorest and compare the output', () => {
let finalResult = true;
const allTests: Array<Promise<boolean>> = [];
for (const rp of ['appplatform', 'compute', 'signalr']) {
for (const rp of ['appplatform', 'appplatform-remote', 'compute', 'signalr']) {
console.log('Start Processing: ' + rp);
// Remove tmpoutput
@ -108,7 +108,11 @@ describe('Run autorest and compare the output', () => {
Helper.deleteFolderRecursive(tempOutputFolder);
fs.mkdirSync(tempOutputFolder, { recursive: true });
const test = runSingleTest(swaggerDir, rp, [`--output-folder=${tempOutputFolder}`, '--debug', ..._.get(extraOptions, rp, [])], outputFolder, tempOutputFolder);
const flags = [`--output-folder=${tempOutputFolder}`, '--debug', ..._.get(extraOptions, rp, [])];
if (rp === 'signalr') {
flags.push('--testmodeler.export-explicit-type');
}
const test = runSingleTest(swaggerDir, rp, flags, outputFolder, tempOutputFolder);
allTests.push(test);
}
if ((process.env['PARALELL_TEST'] || 'false').toLowerCase() === 'true') {

Просмотреть файл

@ -17,6 +17,7 @@ describe('TestModeler functions', () => {
getValue: jest.fn().mockResolvedValue({
testmodeler: {
'export-codemodel': true,
'export-explicit-type': true,
},
}),
});
@ -25,7 +26,7 @@ describe('TestModeler functions', () => {
expect(spyGenMockTests).toHaveBeenCalledTimes(1);
expect(Helper.outputToModelerfour).toHaveBeenCalledTimes(1);
expect(Helper.addCodeModelDump).toHaveBeenCalledTimes(2);
expect(Helper.addCodeModelDump).toHaveBeenCalledTimes(3);
expect(Helper.dump).toHaveBeenCalledTimes(1);
});

Просмотреть файл

@ -0,0 +1,20 @@
# AppPlatform
> see https://aka.ms/autorest
> This is the AutoRest configuration file for AppPlatform.
```yaml
openapi-type: arm
azure-arm: true
require:
- https://github.com/Azure/azure-rest-api-specs/blob/c943ce5e08690d4b0c840245a6f6f3ed28e56886/specification/appplatform/resource-manager/readme.md
clear-output-folder: true
tag: package-preview-2020-11
test-resources:
- test: Microsoft.AppPlatform/preview/2020-11-01-preview/scenarios/Spring.yaml
testmodeler:
api-scenario-loader-option:
fileRoot: https://github.com/Azure/azure-rest-api-specs/blob/eb829ed4739fccb03dd2327b7762392e74c80ae4/specification/appplatform/resource-manager
swaggerFilePaths:
- 'Microsoft.AppPlatform/preview/2020-11-01-preview/appplatform.json'
```

Просмотреть файл

@ -18,13 +18,13 @@
"runtimeVersion": "Java_8"
},
"instances": null
},
"sku": {
"name": "S0",
"tier": "Standard",
"capacity": 1
}
},
"sku": {
"name": "S0",
"tier": "Standard",
"capacity": 1
},
"api-version": "2020-11-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"resourceGroupName": "myResourceGroup",

Просмотреть файл

@ -1,3 +1,4 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/documentation/api-scenario/references/v1.2/schema.json
scope: ResourceGroup
variables:
@ -56,13 +57,11 @@ scenarios:
- step: Services_Get
exampleFile: ../examples/Services_Get.json
resourceName: myservice
- step: Services_Update
resourceName: myservice
operationId: Services_Update
resourceUpdate:
- replace: /tags
exampleFile: ../examples/Services_Update.json
requestUpdate:
- replace: /resource/tags
value:
hello: world
created-by: api-test
@ -83,8 +82,8 @@ scenarios:
exampleFile: ../examples/Certificates_CreateOrUpdate.json
variables:
certificateName: asc-certificate
resourceUpdate:
- replace: /properties
requestUpdate:
- replace: /certificateResource/properties
value:
vaultUri: https://integration-test-prod.vault.azure.net/
keyVaultCertName: pfx-cert
@ -109,8 +108,8 @@ scenarios:
- step: ConfigServers_UpdatePut
exampleFile: ../examples/ConfigServers_UpdatePut.json
resourceUpdate:
- replace: /properties/configServer/gitProperty
requestUpdate:
- replace: /configServerResource/properties/configServer/gitProperty
value:
uri: https://github.com/VSChina/asc-config-server-test-public.git
label: master
@ -118,8 +117,8 @@ scenarios:
- step: ConfigServers_UpdatePatch
exampleFile: ../examples/ConfigServers_UpdatePatch.json
resourceUpdate:
- replace: /properties/configServer/gitProperty
requestUpdate:
- replace: /configServerResource/properties/configServer/gitProperty
value:
uri: https://github.com/azure-samples/spring-petclinic-microservices-config
@ -129,69 +128,63 @@ scenarios:
# Monitoring
- step: MonitoringSettings_UpdatePut
exampleFile: ../examples/MonitoringSettings_UpdatePut.json
resourceUpdate:
- replace: /properties
requestUpdate:
- replace: /monitoringSettingResource/properties
value:
traceEnabled: true
appInsightsInstrumentationKey: "$(insightsInstrumentationKey)"
appInsightsSamplingRate: 50.0
resourceName: monitorSetting
- step: MonitoringSettings_Get
exampleFile: ../examples/MonitoringSettings_Get.json
- step: MonitoringSettings_UpdatePatch
resourceName: monitorSetting
operationId: MonitoringSettings_UpdatePatch
resourceUpdate:
- replace: /properties/appInsightsSamplingRate
exampleFile: ../examples/MonitoringSettings_UpdatePatch.json
requestUpdate:
- replace: /monitoringSettingResource/properties/appInsightsSamplingRate
value: 100
# Apps
- step: Apps_Create
exampleFile: ../examples/Apps_CreateOrUpdate.json
resourceUpdate:
- remove: /properties/temporaryDisk
- remove: /properties/persistentDisk
- replace: /properties/public
requestUpdate:
- remove: /appResource/properties/temporaryDisk
- remove: /appResource/properties/persistentDisk
- replace: /appResource/properties/public
value: false
- step: Apps_Get
exampleFile: ../examples/Apps_Get.json
resourceName: app01
- step: Deployments_CreateOrUpdate_Default
exampleFile: ../examples/Deployments_CreateOrUpdate.json
variables:
deploymentName: default
resourceUpdate:
- replace: /properties/source/type
requestUpdate:
- replace: /deploymentResource/properties/source/type
value: Jar
- replace: /properties/source/relativePath
- replace: /deploymentResource/properties/source/relativePath
value: "<default>"
- step: Deployments_Get
exampleFile: ../examples/Deployments_Get.json
variables:
deploymentName: default
resourceName: default
- step: Apps_Update_ActiveDeployment # PATCH
resourceName: app01
operationId: Apps_Update
resourceUpdate:
- replace: /properties/activeDeploymentName
exampleFile: ../examples/Apps_Update.json
requestUpdate:
- replace: /appResource/properties/activeDeploymentName
value: default
- step: Apps_Update_Disk # PATCH
resourceName: app01
operationId: Apps_Update
resourceUpdate:
- replace: /properties/temporaryDisk
exampleFile: ../examples/Apps_Update.json
requestUpdate:
- replace: /appResource/properties/temporaryDisk
value: { "sizeInGB": 3, "mountPath": "/tmpdisk" }
- replace: /properties/persistentDisk
- replace: /appResource/properties/persistentDisk
value: { "sizeInGB": 10, "mountPath": "/data" }
- replace: /properties/public
- replace: /appResource/properties/public
value: true
- step: Apps_List
@ -202,22 +195,22 @@ scenarios:
exampleFile: ../examples/Bindings_CreateOrUpdate.json
variables:
bindingName: mysql-binding
resourceUpdate:
- replace: /properties/resourceId
requestUpdate:
- replace: /bindingResource/properties/resourceId
value: "/subscriptions/b46590cb-a111-4b84-935f-c305aaf1f424/resourceGroups/mary-west/providers/Microsoft.DBforMySQL/servers/fake-sql"
- replace: /properties/key
- replace: /bindingResource/properties/key
value: $(mysqlKey)
- replace: /properties/bindingParameters
- replace: /bindingResource/properties/bindingParameters
value: { "databaseName": "mysqldb", "username": "test" }
- step: Bindings_Update # PATCH
exampleFile: ../examples/Bindings_Update.json
variables:
bindingName: mysql-binding
resourceUpdate:
- replace: /properties/key
requestUpdate:
- replace: /bindingResource/properties/key
value: $(mysqlKey)
- replace: /properties/bindingParameters
- replace: /bindingResource/properties/bindingParameters
value: { "databaseName": "mysqldb2", "username": "test2" }
- step: Bindings_Get
@ -244,16 +237,16 @@ scenarios:
exampleFile: ../examples/CustomDomains_CreateOrUpdate.json
variables:
domainName: $(dnsCname).$(customDomainName)
resourceUpdate:
- replace: /properties
requestUpdate:
- replace: /domainResource/properties
value: { "certName": "asc-certificate" }
- step: CustomDomains_Update
exampleFile: ../examples/CustomDomains_Update.json
variables:
domainName: $(dnsCname).$(customDomainName)
resourceUpdate:
- replace: /properties
requestUpdate:
- replace: /domainResource/properties
value: { "certName": "asc-certificate" } # TODO: use another cert
- step: CustomDomains_Get
@ -286,20 +279,18 @@ scenarios:
exampleFile: ../examples/Deployments_CreateOrUpdate.json
variables:
deploymentName: blue
resourceName: deploymentBlue
resourceUpdate:
- replace: /sku/capacity
requestUpdate:
- replace: /deploymentResource/sku/capacity
value: 2
- replace: /properties/source/type
- replace: /deploymentResource/properties/source/type
value: Jar
- replace: /properties/source/relativePath
- replace: /deploymentResource/properties/source/relativePath
value: $(relativePath)
- step: Apps_Update # PATCH
resourceName: app01
operationId: Apps_Update
resourceUpdate:
- replace: /properties/activeDeploymentName
exampleFile: ../examples/Apps_Update.json
requestUpdate:
- replace: /appResource/properties/activeDeploymentName
value: blue
- step: Deployments_Restart