зеркало из https://github.com/Azure/autorest.az.git
fix issues (#499)
Co-authored-by: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com>
This commit is contained in:
Родитель
62610e8c02
Коммит
1928d83e65
|
@ -1905,7 +1905,7 @@ export class CodeModelCliImpl implements CodeModelAz {
|
|||
example.Parameters = this.ConvertToCliParameters(params);
|
||||
example.MethodResponses = this.Method.responses || [];
|
||||
example.Method_IsLongRun = this.Method.extensions?.['x-ms-long-running-operation'] ? true : false;
|
||||
if (this.Method_GetSplitOriginalOperation && Object.keys(this.Examples).length>1) {
|
||||
if (this.Method_GetSplitOriginalOperation) {
|
||||
//filter example by name for generic createorupdate
|
||||
if(this.Command_MethodName.toLowerCase()=="update" && !id.toLowerCase().endsWith("_update"))
|
||||
return;
|
||||
|
|
|
@ -59,8 +59,8 @@ export function GenerateAzureCliActions(model: CodeModelAz): string[] {
|
|||
|
||||
if (outputCode.length != 0) {
|
||||
header.addImport("argparse");
|
||||
header.addFromImport("knack.util", ["CLIError"]);
|
||||
header.addFromImport("collections", ["defaultdict"]);
|
||||
header.addFromImport("knack.util", ["CLIError"]);
|
||||
output = header.getLines().concat(outputCode);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -19,6 +19,7 @@ export function GenerateAzureCliTestInit(model: CodeModelAz): string[] {
|
|||
output.push("# regenerated.");
|
||||
output.push("# --------------------------------------------------------------------------");
|
||||
output.push("import inspect");
|
||||
output.push("import logging")
|
||||
output.push("import os");
|
||||
output.push("import sys");
|
||||
output.push("import traceback");
|
||||
|
@ -28,12 +29,15 @@ export function GenerateAzureCliTestInit(model: CodeModelAz): string[] {
|
|||
output.push("from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError");
|
||||
output.push("");
|
||||
output.push("");
|
||||
output.push("logger = logging.getLogger('azure.cli.testsdk')");
|
||||
output.push("logger.addHandler(logging.StreamHandler())");
|
||||
output.push("__path__ = __import__('pkgutil').extend_path(__path__, __name__)");
|
||||
output.push("exceptions = []");
|
||||
output.push('test_map = dict()');
|
||||
output.push('SUCCESSED = "successed"');
|
||||
output.push('FAILED = "failed"');
|
||||
output.push('');
|
||||
output.push('');
|
||||
output.push('def try_manual(func):');
|
||||
output.push(' def import_manual_function(origin_func):');
|
||||
output.push(' from importlib import import_module');
|
||||
|
@ -53,14 +57,15 @@ export function GenerateAzureCliTestInit(model: CodeModelAz): string[] {
|
|||
output.push(' func_to_call = func');
|
||||
output.push(' try:');
|
||||
output.push(' func_to_call = import_manual_function(func)');
|
||||
output.push(' print("Found manual override for {}(...)".format(func.__name__))')
|
||||
output.push(' func_to_call = import_manual_function(func)');
|
||||
output.push(' logger.info("Found manual override for %s(...)", func.__name__)')
|
||||
output.push(' except (ImportError, AttributeError):');
|
||||
output.push(' pass');
|
||||
output.push(' return func_to_call');
|
||||
output.push('');
|
||||
output.push(' def wrapper(*args, **kwargs):');
|
||||
output.push(' func_to_call = get_func_to_call()');
|
||||
output.push(' print("running {}()...".format(func.__name__))');
|
||||
output.push(' logger.info("running %s()...", func.__name__)');
|
||||
output.push(' try:');
|
||||
output.push(' test_map[func.__name__] = dict()');
|
||||
output.push(' test_map[func.__name__]["result"] = SUCCESSED');
|
||||
|
@ -69,16 +74,18 @@ export function GenerateAzureCliTestInit(model: CodeModelAz): string[] {
|
|||
output.push(' test_map[func.__name__]["error_normalized"] = ""');
|
||||
output.push(' test_map[func.__name__]["start_dt"] = dt.datetime.utcnow()');
|
||||
output.push(' ret = func_to_call(*args, **kwargs)');
|
||||
output.push(' except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, JMESPathCheckAssertionError) as e:');
|
||||
output.push(' except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit,');
|
||||
output.push(' JMESPathCheckAssertionError) as e:');
|
||||
output.push(' test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()');
|
||||
output.push(' test_map[func.__name__]["result"] = FAILED');
|
||||
output.push(' test_map[func.__name__]["error_message"] = str(e).replace("\\r\\n", " ").replace("\\n", " ")[:500]');
|
||||
output.push(' test_map[func.__name__]["error_stack"] = traceback.format_exc().replace("\\r\\n", " ").replace("\\n", " ")[:500]');
|
||||
output.push(' print("--------------------------------------")');
|
||||
output.push(' print("step exception: ", e)');
|
||||
output.push(' print("--------------------------------------", file=sys.stderr)');
|
||||
output.push(' print("step exception in {}: {}".format(func.__name__, e), file=sys.stderr)');
|
||||
output.push(' traceback.print_exc()');
|
||||
output.push(' test_map[func.__name__]["error_stack"] = traceback.format_exc().replace(');
|
||||
output.push(' "\\r\\n", " ").replace("\\n", " ")[:500]');
|
||||
output.push(' logger.info("--------------------------------------")');
|
||||
output.push(' logger.info("step exception: %s", e)');
|
||||
output.push(' logger.error("--------------------------------------")');
|
||||
output.push(' logger.error("step exception in %s: %s", func.__name__, e)');
|
||||
output.push(' logger.info(traceback.format_exc())');
|
||||
output.push(' exceptions.append((func.__name__, sys.exc_info()))');
|
||||
output.push(' else:');
|
||||
output.push(' test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()');
|
||||
|
@ -88,12 +95,12 @@ export function GenerateAzureCliTestInit(model: CodeModelAz): string[] {
|
|||
output.push(' return get_func_to_call()');
|
||||
output.push(' return wrapper');
|
||||
output.push('');
|
||||
output.push('');
|
||||
output.push('def calc_coverage(filename):');
|
||||
output.push(' filename = filename.split(".")[0]');
|
||||
output.push(' coverage_name = filename + "_coverage.md"');
|
||||
output.push(' with open(coverage_name, "w") as f:');
|
||||
output.push(' f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\\n")');
|
||||
output.push(' failed = 0');
|
||||
output.push(' total = len(test_map)');
|
||||
output.push(' covered = 0');
|
||||
output.push(' for k, v in test_map.items():');
|
||||
|
@ -102,10 +109,12 @@ export function GenerateAzureCliTestInit(model: CodeModelAz): string[] {
|
|||
output.push(' continue');
|
||||
output.push(' if v["result"] == SUCCESSED:');
|
||||
output.push(' covered += 1');
|
||||
output.push(' f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|{end_dt}|\\n".format(step_name=k, **v))');
|
||||
output.push(' f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|"');
|
||||
output.push(' "{end_dt}|\\n".format(step_name=k, **v))');
|
||||
output.push(' f.write("Coverage: {}/{}\\n".format(covered, total))');
|
||||
output.push(' print("Create coverage\\n", file=sys.stderr)');
|
||||
output.push('');
|
||||
output.push('');
|
||||
output.push('def raise_if():');
|
||||
output.push(' if exceptions:');
|
||||
output.push(' if len(exceptions) <= 1:');
|
||||
|
|
|
@ -199,8 +199,10 @@ function InitiateDependencies(model: CodeModelAz, imports: string[], decorators:
|
|||
for (let [class_name, kargs_key, hasCreateExample, object_name] of internalObjects) {
|
||||
if (hasCreateExample && model.RandomizeNames)
|
||||
{
|
||||
let snakeName = ToSnakeCase(class_name);
|
||||
ToMultiLine(` '${kargs_key}': self.create_random_name(prefix='${object_name}'[:${Math.floor(object_name.length/2)}], length=${object_name.length}),`, initiates);
|
||||
const RANDOMIZE_MIN_LEN = 4;
|
||||
let prefixLen = Math.floor(object_name.length/2);
|
||||
if(object_name.length-prefixLen<RANDOMIZE_MIN_LEN) prefixLen = Math.max(object_name.length-RANDOMIZE_MIN_LEN, 0);
|
||||
ToMultiLine(` '${kargs_key}': self.create_random_name(prefix='${object_name}'[:${prefixLen}], length=${Math.max(object_name.length, RANDOMIZE_MIN_LEN)}),`, initiates);
|
||||
}
|
||||
else
|
||||
initiates.push(` '${kargs_key}': '${object_name}',`); // keep the original name in example if there is no create example in the test-scenario
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
# pylint: disable=protected-access
|
||||
|
||||
import argparse
|
||||
from knack.util import CLIError
|
||||
from collections import defaultdict
|
||||
from knack.util import CLIError
|
||||
|
||||
|
||||
class AddPolicySigningCertificatesKeys(argparse._AppendAction):
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# regenerated.
|
||||
# --------------------------------------------------------------------------
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
@ -18,12 +19,15 @@ from azure.core.exceptions import AzureError
|
|||
from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError
|
||||
|
||||
|
||||
logger = logging.getLogger('azure.cli.testsdk')
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
||||
exceptions = []
|
||||
test_map = dict()
|
||||
SUCCESSED = "successed"
|
||||
FAILED = "failed"
|
||||
|
||||
|
||||
def try_manual(func):
|
||||
def import_manual_function(origin_func):
|
||||
from importlib import import_module
|
||||
|
@ -43,14 +47,15 @@ def try_manual(func):
|
|||
func_to_call = func
|
||||
try:
|
||||
func_to_call = import_manual_function(func)
|
||||
print("Found manual override for {}(...)".format(func.__name__))
|
||||
func_to_call = import_manual_function(func)
|
||||
logger.info("Found manual override for %s(...)", func.__name__)
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
return func_to_call
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
func_to_call = get_func_to_call()
|
||||
print("running {}()...".format(func.__name__))
|
||||
logger.info("running %s()...", func.__name__)
|
||||
try:
|
||||
test_map[func.__name__] = dict()
|
||||
test_map[func.__name__]["result"] = SUCCESSED
|
||||
|
@ -59,16 +64,18 @@ def try_manual(func):
|
|||
test_map[func.__name__]["error_normalized"] = ""
|
||||
test_map[func.__name__]["start_dt"] = dt.datetime.utcnow()
|
||||
ret = func_to_call(*args, **kwargs)
|
||||
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, JMESPathCheckAssertionError) as e:
|
||||
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit,
|
||||
JMESPathCheckAssertionError) as e:
|
||||
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
|
||||
test_map[func.__name__]["result"] = FAILED
|
||||
test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500]
|
||||
test_map[func.__name__]["error_stack"] = traceback.format_exc().replace("\r\n", " ").replace("\n", " ")[:500]
|
||||
print("--------------------------------------")
|
||||
print("step exception: ", e)
|
||||
print("--------------------------------------", file=sys.stderr)
|
||||
print("step exception in {}: {}".format(func.__name__, e), file=sys.stderr)
|
||||
traceback.print_exc()
|
||||
test_map[func.__name__]["error_stack"] = traceback.format_exc().replace(
|
||||
"\r\n", " ").replace("\n", " ")[:500]
|
||||
logger.info("--------------------------------------")
|
||||
logger.info("step exception: %s", e)
|
||||
logger.error("--------------------------------------")
|
||||
logger.error("step exception in %s: %s", func.__name__, e)
|
||||
logger.info(traceback.format_exc())
|
||||
exceptions.append((func.__name__, sys.exc_info()))
|
||||
else:
|
||||
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
|
||||
|
@ -78,12 +85,12 @@ def try_manual(func):
|
|||
return get_func_to_call()
|
||||
return wrapper
|
||||
|
||||
|
||||
def calc_coverage(filename):
|
||||
filename = filename.split(".")[0]
|
||||
coverage_name = filename + "_coverage.md"
|
||||
with open(coverage_name, "w") as f:
|
||||
f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n")
|
||||
failed = 0
|
||||
total = len(test_map)
|
||||
covered = 0
|
||||
for k, v in test_map.items():
|
||||
|
@ -92,10 +99,12 @@ def calc_coverage(filename):
|
|||
continue
|
||||
if v["result"] == SUCCESSED:
|
||||
covered += 1
|
||||
f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|{end_dt}|\n".format(step_name=k, **v))
|
||||
f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|"
|
||||
"{end_dt}|\n".format(step_name=k, **v))
|
||||
f.write("Coverage: {}/{}\n".format(covered, total))
|
||||
print("Create coverage\n", file=sys.stderr)
|
||||
|
||||
|
||||
def raise_if():
|
||||
if exceptions:
|
||||
if len(exceptions) <= 1:
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# regenerated.
|
||||
# --------------------------------------------------------------------------
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
@ -18,12 +19,15 @@ from azure.core.exceptions import AzureError
|
|||
from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError
|
||||
|
||||
|
||||
logger = logging.getLogger('azure.cli.testsdk')
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
||||
exceptions = []
|
||||
test_map = dict()
|
||||
SUCCESSED = "successed"
|
||||
FAILED = "failed"
|
||||
|
||||
|
||||
def try_manual(func):
|
||||
def import_manual_function(origin_func):
|
||||
from importlib import import_module
|
||||
|
@ -43,14 +47,15 @@ def try_manual(func):
|
|||
func_to_call = func
|
||||
try:
|
||||
func_to_call = import_manual_function(func)
|
||||
print("Found manual override for {}(...)".format(func.__name__))
|
||||
func_to_call = import_manual_function(func)
|
||||
logger.info("Found manual override for %s(...)", func.__name__)
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
return func_to_call
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
func_to_call = get_func_to_call()
|
||||
print("running {}()...".format(func.__name__))
|
||||
logger.info("running %s()...", func.__name__)
|
||||
try:
|
||||
test_map[func.__name__] = dict()
|
||||
test_map[func.__name__]["result"] = SUCCESSED
|
||||
|
@ -59,16 +64,18 @@ def try_manual(func):
|
|||
test_map[func.__name__]["error_normalized"] = ""
|
||||
test_map[func.__name__]["start_dt"] = dt.datetime.utcnow()
|
||||
ret = func_to_call(*args, **kwargs)
|
||||
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, JMESPathCheckAssertionError) as e:
|
||||
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit,
|
||||
JMESPathCheckAssertionError) as e:
|
||||
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
|
||||
test_map[func.__name__]["result"] = FAILED
|
||||
test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500]
|
||||
test_map[func.__name__]["error_stack"] = traceback.format_exc().replace("\r\n", " ").replace("\n", " ")[:500]
|
||||
print("--------------------------------------")
|
||||
print("step exception: ", e)
|
||||
print("--------------------------------------", file=sys.stderr)
|
||||
print("step exception in {}: {}".format(func.__name__, e), file=sys.stderr)
|
||||
traceback.print_exc()
|
||||
test_map[func.__name__]["error_stack"] = traceback.format_exc().replace(
|
||||
"\r\n", " ").replace("\n", " ")[:500]
|
||||
logger.info("--------------------------------------")
|
||||
logger.info("step exception: %s", e)
|
||||
logger.error("--------------------------------------")
|
||||
logger.error("step exception in %s: %s", func.__name__, e)
|
||||
logger.info(traceback.format_exc())
|
||||
exceptions.append((func.__name__, sys.exc_info()))
|
||||
else:
|
||||
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
|
||||
|
@ -78,12 +85,12 @@ def try_manual(func):
|
|||
return get_func_to_call()
|
||||
return wrapper
|
||||
|
||||
|
||||
def calc_coverage(filename):
|
||||
filename = filename.split(".")[0]
|
||||
coverage_name = filename + "_coverage.md"
|
||||
with open(coverage_name, "w") as f:
|
||||
f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n")
|
||||
failed = 0
|
||||
total = len(test_map)
|
||||
covered = 0
|
||||
for k, v in test_map.items():
|
||||
|
@ -92,10 +99,12 @@ def calc_coverage(filename):
|
|||
continue
|
||||
if v["result"] == SUCCESSED:
|
||||
covered += 1
|
||||
f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|{end_dt}|\n".format(step_name=k, **v))
|
||||
f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|"
|
||||
"{end_dt}|\n".format(step_name=k, **v))
|
||||
f.write("Coverage: {}/{}\n".format(covered, total))
|
||||
print("Create coverage\n", file=sys.stderr)
|
||||
|
||||
|
||||
def raise_if():
|
||||
if exceptions:
|
||||
if len(exceptions) <= 1:
|
||||
|
|
|
@ -3979,7 +3979,13 @@
|
|||
"type": "string",
|
||||
"enum": [
|
||||
"On",
|
||||
"Off"
|
||||
"Off",
|
||||
"fakeValue1",
|
||||
"fakeValue2",
|
||||
"fakeValue3",
|
||||
"fakeValue4",
|
||||
"fakeValue5",
|
||||
"fakeValue6"
|
||||
],
|
||||
"x-ms-enum": {
|
||||
"name": "IntegrationRuntimeAutoUpdate",
|
||||
|
|
|
@ -236,9 +236,10 @@ def load_arguments(self, _):
|
|||
c.argument('factory_name', type=str, help='The factory name.', id_part='name')
|
||||
c.argument('integration_runtime_name', options_list=['--name', '-n'], type=str, help='The integration runtime '
|
||||
'name.', id_part='child_name_1')
|
||||
c.argument('auto_update', arg_type=get_enum_type(['On', 'Off']), help='Enables or disables the auto-update '
|
||||
'feature of the self-hosted integration runtime. See https://go.microsoft.com/fwlink/?linkid=854189.'
|
||||
'')
|
||||
c.argument('auto_update', arg_type=get_enum_type(['On', 'Off', 'fakeValue1', 'fakeValue2', 'fakeValue3', ''
|
||||
'fakeValue4', 'fakeValue5', 'fakeValue6']), help='Enables or '
|
||||
'disables the auto-update feature of the self-hosted integration runtime. See '
|
||||
'https://go.microsoft.com/fwlink/?linkid=854189.')
|
||||
c.argument('update_delay_offset', type=str, help='The time offset (in hours) in the day, e.g., PT03H is 3 '
|
||||
'hours. The integration runtime auto update will happen on that time.')
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
# pylint: disable=protected-access
|
||||
|
||||
import argparse
|
||||
from knack.util import CLIError
|
||||
from collections import defaultdict
|
||||
from knack.util import CLIError
|
||||
|
||||
|
||||
class AddFactoryVstsConfiguration(argparse.Action):
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# regenerated.
|
||||
# --------------------------------------------------------------------------
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
@ -18,12 +19,15 @@ from azure.core.exceptions import AzureError
|
|||
from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError
|
||||
|
||||
|
||||
logger = logging.getLogger('azure.cli.testsdk')
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
||||
exceptions = []
|
||||
test_map = dict()
|
||||
SUCCESSED = "successed"
|
||||
FAILED = "failed"
|
||||
|
||||
|
||||
def try_manual(func):
|
||||
def import_manual_function(origin_func):
|
||||
from importlib import import_module
|
||||
|
@ -43,14 +47,15 @@ def try_manual(func):
|
|||
func_to_call = func
|
||||
try:
|
||||
func_to_call = import_manual_function(func)
|
||||
print("Found manual override for {}(...)".format(func.__name__))
|
||||
func_to_call = import_manual_function(func)
|
||||
logger.info("Found manual override for %s(...)", func.__name__)
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
return func_to_call
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
func_to_call = get_func_to_call()
|
||||
print("running {}()...".format(func.__name__))
|
||||
logger.info("running %s()...", func.__name__)
|
||||
try:
|
||||
test_map[func.__name__] = dict()
|
||||
test_map[func.__name__]["result"] = SUCCESSED
|
||||
|
@ -59,16 +64,18 @@ def try_manual(func):
|
|||
test_map[func.__name__]["error_normalized"] = ""
|
||||
test_map[func.__name__]["start_dt"] = dt.datetime.utcnow()
|
||||
ret = func_to_call(*args, **kwargs)
|
||||
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, JMESPathCheckAssertionError) as e:
|
||||
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit,
|
||||
JMESPathCheckAssertionError) as e:
|
||||
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
|
||||
test_map[func.__name__]["result"] = FAILED
|
||||
test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500]
|
||||
test_map[func.__name__]["error_stack"] = traceback.format_exc().replace("\r\n", " ").replace("\n", " ")[:500]
|
||||
print("--------------------------------------")
|
||||
print("step exception: ", e)
|
||||
print("--------------------------------------", file=sys.stderr)
|
||||
print("step exception in {}: {}".format(func.__name__, e), file=sys.stderr)
|
||||
traceback.print_exc()
|
||||
test_map[func.__name__]["error_stack"] = traceback.format_exc().replace(
|
||||
"\r\n", " ").replace("\n", " ")[:500]
|
||||
logger.info("--------------------------------------")
|
||||
logger.info("step exception: %s", e)
|
||||
logger.error("--------------------------------------")
|
||||
logger.error("step exception in %s: %s", func.__name__, e)
|
||||
logger.info(traceback.format_exc())
|
||||
exceptions.append((func.__name__, sys.exc_info()))
|
||||
else:
|
||||
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
|
||||
|
@ -78,12 +85,12 @@ def try_manual(func):
|
|||
return get_func_to_call()
|
||||
return wrapper
|
||||
|
||||
|
||||
def calc_coverage(filename):
|
||||
filename = filename.split(".")[0]
|
||||
coverage_name = filename + "_coverage.md"
|
||||
with open(coverage_name, "w") as f:
|
||||
f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n")
|
||||
failed = 0
|
||||
total = len(test_map)
|
||||
covered = 0
|
||||
for k, v in test_map.items():
|
||||
|
@ -92,10 +99,12 @@ def calc_coverage(filename):
|
|||
continue
|
||||
if v["result"] == SUCCESSED:
|
||||
covered += 1
|
||||
f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|{end_dt}|\n".format(step_name=k, **v))
|
||||
f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|"
|
||||
"{end_dt}|\n".format(step_name=k, **v))
|
||||
f.write("Coverage: {}/{}\n".format(covered, total))
|
||||
print("Create coverage\n", file=sys.stderr)
|
||||
|
||||
|
||||
def raise_if():
|
||||
if exceptions:
|
||||
if len(exceptions) <= 1:
|
||||
|
|
|
@ -90,6 +90,12 @@ class IntegrationRuntimeAutoUpdate(with_metaclass(_CaseInsensitiveEnumMeta, str,
|
|||
|
||||
ON = "On"
|
||||
OFF = "Off"
|
||||
FAKE_VALUE1 = "fakeValue1"
|
||||
FAKE_VALUE2 = "fakeValue2"
|
||||
FAKE_VALUE3 = "fakeValue3"
|
||||
FAKE_VALUE4 = "fakeValue4"
|
||||
FAKE_VALUE5 = "fakeValue5"
|
||||
FAKE_VALUE6 = "fakeValue6"
|
||||
|
||||
class IntegrationRuntimeEdition(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
|
||||
"""The edition for the SSIS Integration Runtime
|
||||
|
|
|
@ -2963,7 +2963,8 @@ class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus):
|
|||
:ivar service_urls: The URLs for the services used in integration runtime backend service.
|
||||
:vartype service_urls: list[str]
|
||||
:ivar auto_update: Whether Self-hosted integration runtime auto update has been turned on.
|
||||
Possible values include: "On", "Off".
|
||||
Possible values include: "On", "Off", "fakeValue1", "fakeValue2", "fakeValue3", "fakeValue4",
|
||||
"fakeValue5", "fakeValue6".
|
||||
:vartype auto_update: str or ~dfaz_management_client.models.IntegrationRuntimeAutoUpdate
|
||||
:ivar version_status: Status of the integration runtime version.
|
||||
:vartype version_status: str
|
||||
|
@ -3820,7 +3821,7 @@ class UpdateIntegrationRuntimeRequest(msrest.serialization.Model):
|
|||
|
||||
:param auto_update: Enables or disables the auto-update feature of the self-hosted integration
|
||||
runtime. See https://go.microsoft.com/fwlink/?linkid=854189. Possible values include: "On",
|
||||
"Off".
|
||||
"Off", "fakeValue1", "fakeValue2", "fakeValue3", "fakeValue4", "fakeValue5", "fakeValue6".
|
||||
:type auto_update: str or ~dfaz_management_client.models.IntegrationRuntimeAutoUpdate
|
||||
:param update_delay_offset: The time offset (in hours) in the day, e.g., PT03H is 3 hours. The
|
||||
integration runtime auto update will happen on that time.
|
||||
|
|
|
@ -3228,7 +3228,8 @@ class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus):
|
|||
:ivar service_urls: The URLs for the services used in integration runtime backend service.
|
||||
:vartype service_urls: list[str]
|
||||
:ivar auto_update: Whether Self-hosted integration runtime auto update has been turned on.
|
||||
Possible values include: "On", "Off".
|
||||
Possible values include: "On", "Off", "fakeValue1", "fakeValue2", "fakeValue3", "fakeValue4",
|
||||
"fakeValue5", "fakeValue6".
|
||||
:vartype auto_update: str or ~dfaz_management_client.models.IntegrationRuntimeAutoUpdate
|
||||
:ivar version_status: Status of the integration runtime version.
|
||||
:vartype version_status: str
|
||||
|
@ -4183,7 +4184,7 @@ class UpdateIntegrationRuntimeRequest(msrest.serialization.Model):
|
|||
|
||||
:param auto_update: Enables or disables the auto-update feature of the self-hosted integration
|
||||
runtime. See https://go.microsoft.com/fwlink/?linkid=854189. Possible values include: "On",
|
||||
"Off".
|
||||
"Off", "fakeValue1", "fakeValue2", "fakeValue3", "fakeValue4", "fakeValue5", "fakeValue6".
|
||||
:type auto_update: str or ~dfaz_management_client.models.IntegrationRuntimeAutoUpdate
|
||||
:param update_delay_offset: The time offset (in hours) in the day, e.g., PT03H is 3 hours. The
|
||||
integration runtime auto update will happen on that time.
|
||||
|
|
|
@ -113,12 +113,6 @@ esourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks
|
|||
helps['managed-network mn scope-assignment update'] = """
|
||||
type: command
|
||||
short-summary: "Creates a scope assignment."
|
||||
examples:
|
||||
- name: Create/Update Managed Network
|
||||
text: |-
|
||||
az managed-network mn scope-assignment update --assigned-managed-network "/subscriptions/subscriptionA/r\
|
||||
esourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork" --scope \
|
||||
"subscriptions/subscriptionC" --name "myScopeAssignment"
|
||||
"""
|
||||
|
||||
helps['managed-network mn scope-assignment delete'] = """
|
||||
|
@ -224,14 +218,6 @@ helps['managed-network mn group update'] = """
|
|||
id: Resource Id
|
||||
|
||||
Multiple actions can be specified by using more than one --subnets argument.
|
||||
examples:
|
||||
- name: Create/Update Managed Network Group
|
||||
text: |-
|
||||
az managed-network mn group update --management-groups "[]" --subnets id="/subscriptionB/resourceGroups/\
|
||||
myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA/subnets/subnetA" --virtual-networks \
|
||||
id="/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA" \
|
||||
--virtual-networks id="/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetB"\
|
||||
--group-name "myManagedNetworkGroup" --managed-network-name "myManagedNetwork" --resource-group "myResourceGroup"
|
||||
"""
|
||||
|
||||
helps['managed-network mn group delete'] = """
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
# pylint: disable=protected-access
|
||||
|
||||
import argparse
|
||||
from knack.util import CLIError
|
||||
from collections import defaultdict
|
||||
from knack.util import CLIError
|
||||
|
||||
|
||||
class AddSubscriptions(argparse._AppendAction):
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# regenerated.
|
||||
# --------------------------------------------------------------------------
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
@ -18,12 +19,15 @@ from azure.core.exceptions import AzureError
|
|||
from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError
|
||||
|
||||
|
||||
logger = logging.getLogger('azure.cli.testsdk')
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
||||
exceptions = []
|
||||
test_map = dict()
|
||||
SUCCESSED = "successed"
|
||||
FAILED = "failed"
|
||||
|
||||
|
||||
def try_manual(func):
|
||||
def import_manual_function(origin_func):
|
||||
from importlib import import_module
|
||||
|
@ -43,14 +47,15 @@ def try_manual(func):
|
|||
func_to_call = func
|
||||
try:
|
||||
func_to_call = import_manual_function(func)
|
||||
print("Found manual override for {}(...)".format(func.__name__))
|
||||
func_to_call = import_manual_function(func)
|
||||
logger.info("Found manual override for %s(...)", func.__name__)
|
||||
except (ImportError, AttributeError):
|
||||
pass
|
||||
return func_to_call
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
func_to_call = get_func_to_call()
|
||||
print("running {}()...".format(func.__name__))
|
||||
logger.info("running %s()...", func.__name__)
|
||||
try:
|
||||
test_map[func.__name__] = dict()
|
||||
test_map[func.__name__]["result"] = SUCCESSED
|
||||
|
@ -59,16 +64,18 @@ def try_manual(func):
|
|||
test_map[func.__name__]["error_normalized"] = ""
|
||||
test_map[func.__name__]["start_dt"] = dt.datetime.utcnow()
|
||||
ret = func_to_call(*args, **kwargs)
|
||||
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, JMESPathCheckAssertionError) as e:
|
||||
except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit,
|
||||
JMESPathCheckAssertionError) as e:
|
||||
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
|
||||
test_map[func.__name__]["result"] = FAILED
|
||||
test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500]
|
||||
test_map[func.__name__]["error_stack"] = traceback.format_exc().replace("\r\n", " ").replace("\n", " ")[:500]
|
||||
print("--------------------------------------")
|
||||
print("step exception: ", e)
|
||||
print("--------------------------------------", file=sys.stderr)
|
||||
print("step exception in {}: {}".format(func.__name__, e), file=sys.stderr)
|
||||
traceback.print_exc()
|
||||
test_map[func.__name__]["error_stack"] = traceback.format_exc().replace(
|
||||
"\r\n", " ").replace("\n", " ")[:500]
|
||||
logger.info("--------------------------------------")
|
||||
logger.info("step exception: %s", e)
|
||||
logger.error("--------------------------------------")
|
||||
logger.error("step exception in %s: %s", func.__name__, e)
|
||||
logger.info(traceback.format_exc())
|
||||
exceptions.append((func.__name__, sys.exc_info()))
|
||||
else:
|
||||
test_map[func.__name__]["end_dt"] = dt.datetime.utcnow()
|
||||
|
@ -78,12 +85,12 @@ def try_manual(func):
|
|||
return get_func_to_call()
|
||||
return wrapper
|
||||
|
||||
|
||||
def calc_coverage(filename):
|
||||
filename = filename.split(".")[0]
|
||||
coverage_name = filename + "_coverage.md"
|
||||
with open(coverage_name, "w") as f:
|
||||
f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n")
|
||||
failed = 0
|
||||
total = len(test_map)
|
||||
covered = 0
|
||||
for k, v in test_map.items():
|
||||
|
@ -92,10 +99,12 @@ def calc_coverage(filename):
|
|||
continue
|
||||
if v["result"] == SUCCESSED:
|
||||
covered += 1
|
||||
f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|{end_dt}|\n".format(step_name=k, **v))
|
||||
f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|"
|
||||
"{end_dt}|\n".format(step_name=k, **v))
|
||||
f.write("Coverage: {}/{}\n".format(covered, total))
|
||||
print("Create coverage\n", file=sys.stderr)
|
||||
|
||||
|
||||
def raise_if():
|
||||
if exceptions:
|
||||
if len(exceptions) <= 1:
|
||||
|
|
|
@ -151,6 +151,8 @@ export function ToMultiLine(sentence: string, output: string[] = undefined, maxL
|
|||
let indent = 0;
|
||||
let spaceNum = 0;
|
||||
let strStart = -1;
|
||||
let inStrTags = Array(maxLength).fill(strMode);
|
||||
let indents = [];
|
||||
while (spaceNum < sentence.length && sentence[spaceNum] == ' ') spaceNum++;
|
||||
|
||||
if (strMode) {
|
||||
|
@ -179,10 +181,15 @@ export function ToMultiLine(sentence: string, output: string[] = undefined, maxL
|
|||
strStart = i;
|
||||
}
|
||||
|
||||
if (indent == 0 && sentence[i] == '(') {
|
||||
if (sentence[i] == '(' || sentence[i] == '[') {
|
||||
indents.push(indent);
|
||||
indent = ret[ret.length - 1].length;
|
||||
}
|
||||
if (sentence[i] == ')' || sentence[i] == ']') {
|
||||
indent = indents.pop();
|
||||
}
|
||||
}
|
||||
inStrTags[ret[ret.length - 1].length-1] = inStr;
|
||||
if (ret[ret.length - 1].length >= maxLength) {
|
||||
if (inStr) {
|
||||
let lastNormal = ret[ret.length - 1].length - 1;
|
||||
|
@ -206,7 +213,7 @@ export function ToMultiLine(sentence: string, output: string[] = undefined, maxL
|
|||
if (lastNormal != ret[ret.length - 1].length - 1) {
|
||||
let newLine = ret[ret.length - 1].substr(lastNormal + 1);
|
||||
ret[ret.length - 1] = ret[ret.length - 1].substr(0, lastNormal + 1) + "\\";
|
||||
ret.push(newLine)
|
||||
ret.push(newLine);
|
||||
lastComma = -1;
|
||||
}
|
||||
else {
|
||||
|
@ -221,13 +228,17 @@ export function ToMultiLine(sentence: string, output: string[] = undefined, maxL
|
|||
if (lastNormal != ret[ret.length - 1].length - 1) {
|
||||
let newLine = ' '.repeat(indent > 0 ? indent : spaceNum) + strTag + ret[ret.length - 1].substr(lastNormal + 1);
|
||||
ret[ret.length - 1] = ret[ret.length - 1].substr(0, lastNormal + 1) + strTag;
|
||||
ret.push(newLine)
|
||||
let currentLength = ret[ret.length - 1].length;
|
||||
if (currentLength >= 3 && ret[ret.length - 1][currentLength - 2] == ' ' && ret[ret.length - 1][currentLength - 2] == strTag && (currentLength == 2 || ret[ret.length - 1][currentLength - 3] != "\\")) { // remove empty string in the end of line
|
||||
ret[ret.length - 1] = ret[ret.length - 1].substr(0, currentLength - 2);
|
||||
}
|
||||
ret.push(newLine);
|
||||
lastComma = -1;
|
||||
}
|
||||
else {
|
||||
ret[ret.length - 1] += strTag;
|
||||
let currentLength = ret[ret.length - 1].length;
|
||||
if (currentLength >= 2 && ret[ret.length - 1][currentLength - 2] == strTag && (currentLength == 2 || ret[ret.length - 1][currentLength - 3] != "\\")) { // remove empty string in the end of line
|
||||
if (currentLength >= 3 && ret[ret.length - 1][currentLength - 2] == ' ' && ret[ret.length - 1][currentLength - 2] == strTag && (currentLength == 2 || ret[ret.length - 1][currentLength - 3] != "\\")) { // remove empty string in the end of line
|
||||
ret[ret.length - 1] = ret[ret.length - 1].substr(0, currentLength - 2);
|
||||
}
|
||||
ret.push(' '.repeat(indent > 0 ? indent : spaceNum) + strTag);
|
||||
|
@ -237,6 +248,24 @@ export function ToMultiLine(sentence: string, output: string[] = undefined, maxL
|
|||
}
|
||||
else {
|
||||
if (lastComma >= 0) {
|
||||
//find indent by parathesis before the lastComma
|
||||
let close_para = 0;
|
||||
for (let i=lastComma; i>indent; i--) {
|
||||
if (inStrTags[i]) continue;
|
||||
let currentChar = ret[ret.length - 1][i];
|
||||
if ( currentChar==')' || currentChar==']') close_para++;
|
||||
if (currentChar=='(' || currentChar=='[' ) {
|
||||
if (close_para==0) {
|
||||
indents.push(indent);
|
||||
indent = i + 1;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
close_para--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let newLine = ' '.repeat(indent > 0 ? indent : spaceNum) + ret[ret.length - 1].substr(lastComma + 1).trimLeft();
|
||||
ret[ret.length - 1] = ret[ret.length - 1].substr(0, lastComma + 1);
|
||||
ret.push(newLine);
|
||||
|
|
Загрузка…
Ссылка в новой задаче