neoload 1.3.19.dev2__py3-none-any.whl → 1.3.19.dev4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- neoload/commands/checkvu.py +55 -25
- neoload/commands/project.py +47 -3
- neoload/commands/report.py +3 -16
- neoload/commands/validate.py +3 -3
- neoload/neoload_cli_lib/checkvu_runner.py +327 -50
- neoload/neoload_cli_lib/jar_signature.py +205 -0
- neoload/neoload_cli_lib/resources.py +28 -0
- neoload/neoload_cli_lib/schema_validation.py +80 -15
- neoload/neoload_cli_lib/user_data.py +48 -18
- neoload/resources/certs/__init__.py +1 -0
- neoload/resources/certs/globalsign-code-signing-root-r45.jks +0 -0
- neoload/resources/templates/__init__.py +0 -0
- neoload/resources/templates/default.yaml +140 -0
- neoload/version.py +1 -1
- {neoload-1.3.19.dev2.dist-info → neoload-1.3.19.dev4.dist-info}/METADATA +32 -10
- {neoload-1.3.19.dev2.dist-info → neoload-1.3.19.dev4.dist-info}/RECORD +20 -14
- {neoload-1.3.19.dev2.dist-info → neoload-1.3.19.dev4.dist-info}/WHEEL +1 -1
- {neoload-1.3.19.dev2.dist-info → neoload-1.3.19.dev4.dist-info}/entry_points.txt +0 -0
- {neoload-1.3.19.dev2.dist-info → neoload-1.3.19.dev4.dist-info}/licenses/LICENSE +0 -0
- {neoload-1.3.19.dev2.dist-info → neoload-1.3.19.dev4.dist-info}/top_level.txt +0 -0
neoload/commands/checkvu.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
import os
|
|
2
3
|
import sys
|
|
3
4
|
|
|
@@ -5,27 +6,36 @@ import click
|
|
|
5
6
|
|
|
6
7
|
from neoload_cli_lib import checkvu_runner, cli_exception
|
|
7
8
|
import neoload_cli_lib.schema_validation as schema_validation
|
|
8
|
-
from neoload_cli_lib.schema_validation import __default_schema_url
|
|
9
9
|
|
|
10
10
|
__yaml_extensions = (".yaml", ".yml")
|
|
11
11
|
|
|
12
12
|
@click.command()
|
|
13
|
-
@click.option('-e', '--engine-jar',
|
|
14
|
-
help="CheckVU engine
|
|
15
|
-
"
|
|
13
|
+
@click.option('-e', '--engine-jar', '--jar',
|
|
14
|
+
help="Run this CheckVU engine: a local JAR or a download URL. If omitted, the JAR "
|
|
15
|
+
"already cached for this OS is used. If none is cached, the command fails and "
|
|
16
|
+
"prints the folder where the CheckVU JAR must be copied.",
|
|
16
17
|
metavar="PATH|URL")
|
|
17
18
|
@click.option('-j', '--java', help="Path to the java executable to use. "
|
|
18
19
|
"Defaults to JAVA_HOME/bin/java, then java on the PATH.", metavar="PATH")
|
|
19
20
|
@click.option('-u', '--user-path', help="Run only the specified user path. If omitted, all user paths in the file "
|
|
20
21
|
"are executed sequentially. An unknown name fails and lists the user paths "
|
|
21
22
|
"found in the file.", metavar="NAME")
|
|
22
|
-
@click.option('
|
|
23
|
-
help="
|
|
24
|
-
"
|
|
23
|
+
@click.option('--play-think-time', is_flag=True, default=False,
|
|
24
|
+
help="Play think times defined on pages and delays marked as think time. "
|
|
25
|
+
"Disabled by default. Equivalent to setting CHECKVU_CLI_PLAY_THINK_TIME=1.")
|
|
26
|
+
@click.option('-s', '--as-code-schema', default=None,
|
|
27
|
+
help="NeoLoad as-code schema (URL or local path) to validate PROJECT_FILE against. "
|
|
28
|
+
"When omitted, download schemas/v<schemaVersion>/as-code.schema.json from neoload-models tag 3.4.22. "
|
|
29
|
+
"If schemaVersion is absent, use schemas/v3.0/as-code.schema.json.",
|
|
25
30
|
metavar="PATH|URL")
|
|
26
31
|
@click.option('--ssl-cert', default="",
|
|
27
32
|
help="Path to SSL certificate or write False to disable certificate checking. "
|
|
28
33
|
"Used both for schema validation and the JAR download.")
|
|
34
|
+
@click.option('--unsafe-skip-jar-verification', is_flag=True, default=False,
|
|
35
|
+
help="Unsafe. Run the CheckVU JAR without checking that it is signed by Tricentis. "
|
|
36
|
+
"Intended for development, and for runtimes that ship no jarsigner "
|
|
37
|
+
"(jarsigner is in the JDK, not the JRE, and the check requires it) "
|
|
38
|
+
"when running a local JAR that has already been verified.")
|
|
29
39
|
@click.option('--controller-properties',
|
|
30
40
|
help="Advanced. Path to controller.properties file merged additively into the Controller "
|
|
31
41
|
"configuration; only the keys you set are overridden, other embedded values are kept.",
|
|
@@ -42,12 +52,18 @@ __yaml_extensions = (".yaml", ".yml")
|
|
|
42
52
|
metavar="HOST:PORT")
|
|
43
53
|
@click.option('--app-proxy-username',
|
|
44
54
|
help="Username for --app-proxy authentication (optional). The password is read from environment "
|
|
45
|
-
"variable
|
|
55
|
+
"variable CHECKVU_CLI_APP_PROXY_PASSWORD; there is no flag for it, so it is never "
|
|
46
56
|
"exposed in the process list or CI logs.",
|
|
47
57
|
metavar="USERNAME")
|
|
48
58
|
@click.option('--app-proxy-bypass',
|
|
49
59
|
help="Comma-separated hosts that bypass --app-proxy (e.g. localhost,internal.corp).",
|
|
50
60
|
metavar="HOSTS")
|
|
61
|
+
@click.option('-o', '--output',
|
|
62
|
+
help="Directory that receives checkvu-result.json and the checkvu-content/ request and response "
|
|
63
|
+
"dump. When omitted, nothing is written to disk and the console output is unchanged. "
|
|
64
|
+
"Relative paths resolve from the current directory, not from PROJECT_FILE. The dump is not "
|
|
65
|
+
"redacted: treat it as confidential.",
|
|
66
|
+
metavar="PATH")
|
|
51
67
|
@click.option('-w', '--work-dir',
|
|
52
68
|
help="Directory for engine scratch files and logs. Defaults to a temporary directory. "
|
|
53
69
|
"A directory you supply is never deleted.",
|
|
@@ -55,22 +71,28 @@ __yaml_extensions = (".yaml", ".yml")
|
|
|
55
71
|
@click.option('--keep-temp-work-dir', is_flag=True, default=False,
|
|
56
72
|
help="Keep the temporary work directory after the run instead of deleting it. "
|
|
57
73
|
"Equivalent to setting CHECKVU_CLI_KEEP_TEMP_WORK_DIR=1. "
|
|
58
|
-
"Has no effect when --work-dir is already set, since that directory is never auto-deleted."
|
|
74
|
+
"Has no effect when --work-dir is already set, since that directory is never auto-deleted. "
|
|
75
|
+
"After neoload login, a retained work directory contains the NeoLoad Web token in clear "
|
|
76
|
+
"text in conf/controller.properties; treat it as confidential.")
|
|
59
77
|
@click.argument('project_file')
|
|
60
|
-
def cli(engine_jar, java, user_path, as_code_schema, ssl_cert,
|
|
78
|
+
def cli(engine_jar, java, user_path, play_think_time, as_code_schema, ssl_cert, unsafe_skip_jar_verification,
|
|
61
79
|
controller_properties, load_generator_properties,
|
|
62
|
-
app_proxy, app_proxy_username, app_proxy_bypass, work_dir, keep_temp_work_dir,
|
|
80
|
+
app_proxy, app_proxy_username, app_proxy_bypass, output, work_dir, keep_temp_work_dir,
|
|
63
81
|
project_file):
|
|
64
82
|
""" Validate the User Paths of a NeoLoad as-code Project locally.
|
|
65
83
|
|
|
66
84
|
Runs each User Path once against the application and reports whether
|
|
67
85
|
it completes without blocking errors. This is not a load test: no
|
|
68
86
|
Population, no Scenario, no Result. Exits 0 when every User Path passes, 1
|
|
69
|
-
otherwise
|
|
87
|
+
otherwise. Use --output to also write checkvu-result.json and the full
|
|
88
|
+
request and response dump to a directory.
|
|
70
89
|
|
|
71
90
|
PROJECT_FILE is the as-code Project YAML file. Its parent directory is the
|
|
72
91
|
Project root; colocated assets such as CSV files must live under that
|
|
73
92
|
root.
|
|
93
|
+
|
|
94
|
+
A java executable is required to run the checkVU. Prefer a JDK over JRE so
|
|
95
|
+
that the CLI can check the JAR's integrity
|
|
74
96
|
"""
|
|
75
97
|
if not project_file.lower().endswith(__yaml_extensions):
|
|
76
98
|
raise cli_exception.CliException("Project file must be a yaml (\".yaml\", \".yml\") file: " + project_file)
|
|
@@ -81,18 +103,26 @@ def cli(engine_jar, java, user_path, as_code_schema, ssl_cert,
|
|
|
81
103
|
java_executable = checkvu_runner.resolve_java(java)
|
|
82
104
|
checkvu_runner.check_java_version(java_executable)
|
|
83
105
|
|
|
84
|
-
resolved_jar = checkvu_runner.resolve_jar(engine_jar, ssl_cert
|
|
106
|
+
resolved_jar = checkvu_runner.resolve_jar(engine_jar, ssl_cert, java_executable,
|
|
107
|
+
verify_signature=not unsafe_skip_jar_verification)
|
|
108
|
+
logging.debug("Using CheckVU JAR at '%s'", os.path.abspath(resolved_jar))
|
|
109
|
+
if not engine_jar:
|
|
110
|
+
checkvu_runner.check_jar_build(java_executable, resolved_jar)
|
|
85
111
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
112
|
+
with checkvu_runner.prepare_controller_properties(
|
|
113
|
+
controller_properties) as resolved_controller_properties:
|
|
114
|
+
command = checkvu_runner.build_command(
|
|
115
|
+
java_executable, resolved_jar, project_file,
|
|
116
|
+
user_path=user_path,
|
|
117
|
+
play_think_time=play_think_time,
|
|
118
|
+
controller_properties=resolved_controller_properties,
|
|
119
|
+
load_generator_properties=load_generator_properties,
|
|
120
|
+
app_proxy=app_proxy,
|
|
121
|
+
app_proxy_username=app_proxy_username,
|
|
122
|
+
app_proxy_bypass=app_proxy_bypass,
|
|
123
|
+
output=output,
|
|
124
|
+
work_dir=work_dir,
|
|
125
|
+
keep_temp_work_dir=keep_temp_work_dir,
|
|
126
|
+
)
|
|
127
|
+
exit_code = checkvu_runner.run_checkvu(command)
|
|
98
128
|
sys.exit(exit_code)
|
neoload/commands/project.py
CHANGED
|
@@ -4,18 +4,30 @@ import click
|
|
|
4
4
|
import urllib.parse as urlparse
|
|
5
5
|
from commands import test_settings
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from neoload_cli_lib import user_data, tools, rest_crud, neoLoad_project
|
|
7
|
+
from neoload_cli_lib import user_data, tools, rest_crud, neoLoad_project, cli_exception, resources
|
|
8
|
+
|
|
9
|
+
__template_namespace = 'resources.templates'
|
|
10
|
+
__template_filename = 'default.yaml'
|
|
11
|
+
__project_yaml_name = 'default.yaml'
|
|
8
12
|
|
|
9
13
|
|
|
10
14
|
@click.command()
|
|
11
|
-
@click.argument("command", required=True, type=click.Choice(['up', 'upload', 'meta']))
|
|
15
|
+
@click.argument("command", required=True, type=click.Choice(['create', 'up', 'upload', 'meta']))
|
|
12
16
|
@click.option("--path", "-p", type=click.Path(exists=True), default=os.getcwd(),
|
|
13
17
|
help="Path of project folder, zip or yml file. . is default value")
|
|
14
18
|
@click.option("--save", "-s", type=click.Path(exists=False),
|
|
15
19
|
help="Path to a (non-existent) file ending in .zip to preserve what was uploaded")
|
|
16
20
|
@click.argument("name_or_id", type=str, required=False)
|
|
17
21
|
def cli(command, name_or_id, path, save):
|
|
18
|
-
"""
|
|
22
|
+
"""
|
|
23
|
+
create # Create a local as-code project folder from the demo yaml template.
|
|
24
|
+
upload # Upload a project to NeoLoad Web test settings (alias: up) .
|
|
25
|
+
meta # Display project metadata from the current test settings .
|
|
26
|
+
"""
|
|
27
|
+
if command == "create":
|
|
28
|
+
create_local_project(name_or_id)
|
|
29
|
+
return
|
|
30
|
+
|
|
19
31
|
rest_crud.set_current_command()
|
|
20
32
|
if not name_or_id or name_or_id == "cur":
|
|
21
33
|
name_or_id = user_data.get_meta(test_settings.meta_key)
|
|
@@ -75,3 +87,35 @@ def meta_data(setting_id):
|
|
|
75
87
|
|
|
76
88
|
def get_endpoint(settings_id: str):
|
|
77
89
|
return rest_crud.base_endpoint_with_workspace() + '/tests/' + settings_id + "/project"
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def create_local_project(project_name):
|
|
93
|
+
if project_name is None:
|
|
94
|
+
raise cli_exception.CliException("Missing project name. Usage: neoload project create <project-name>")
|
|
95
|
+
project_name = project_name.strip()
|
|
96
|
+
if not project_name or project_name in ('.', '..'):
|
|
97
|
+
raise cli_exception.CliException(f"Invalid project name: '{project_name}'.")
|
|
98
|
+
if os.path.sep in project_name or (os.path.altsep and os.path.altsep in project_name):
|
|
99
|
+
raise cli_exception.CliException(
|
|
100
|
+
f"Invalid project name: '{project_name}'. Use a single folder name, not a path."
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
if os.path.exists(project_name):
|
|
104
|
+
raise cli_exception.CliException(
|
|
105
|
+
f"Cannot create project '{project_name}': path already exists."
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
yaml_path = os.path.join(project_name, __project_yaml_name)
|
|
109
|
+
try:
|
|
110
|
+
template = resources.get_resource_as_string(__template_namespace, __template_filename)
|
|
111
|
+
os.mkdir(project_name)
|
|
112
|
+
with open(yaml_path, 'w', encoding='utf-8') as yaml_file:
|
|
113
|
+
yaml_file.write(template)
|
|
114
|
+
except OSError as err:
|
|
115
|
+
raise cli_exception.CliException(f"Failed to create project '{project_name}': {err}") from err
|
|
116
|
+
|
|
117
|
+
print(f"Project '{project_name}' created successfully.")
|
|
118
|
+
print(f" {yaml_path}")
|
|
119
|
+
print()
|
|
120
|
+
print("Next step: verify your project with CheckVU:")
|
|
121
|
+
print(f" neoload checkvu {yaml_path}")
|
neoload/commands/report.py
CHANGED
|
@@ -8,7 +8,7 @@ import statistics
|
|
|
8
8
|
import math
|
|
9
9
|
import time
|
|
10
10
|
|
|
11
|
-
from neoload_cli_lib import tools, rest_crud, user_data, displayer, cli_exception
|
|
11
|
+
from neoload_cli_lib import tools, rest_crud, user_data, displayer, cli_exception, resources
|
|
12
12
|
from dateutil.relativedelta import relativedelta
|
|
13
13
|
|
|
14
14
|
import logging
|
|
@@ -165,19 +165,6 @@ def parse_filter_spec(filter_spec):
|
|
|
165
165
|
return ret
|
|
166
166
|
|
|
167
167
|
|
|
168
|
-
def get_resource_as_string(namespace, file):
|
|
169
|
-
try:
|
|
170
|
-
import importlib.resources as pkg_resources
|
|
171
|
-
except ImportError:
|
|
172
|
-
# Try backported to PY<37 `importlib_resources`.
|
|
173
|
-
import importlib_resources as pkg_resources
|
|
174
|
-
|
|
175
|
-
logging.debug({'namespace': namespace, 'file': file})
|
|
176
|
-
if hasattr(pkg_resources, 'files'): # files is present from Python 3.9
|
|
177
|
-
return pkg_resources.files(namespace).joinpath(file).read_text()
|
|
178
|
-
return pkg_resources.read_text(namespace, file)
|
|
179
|
-
|
|
180
|
-
|
|
181
168
|
def split_path(path):
|
|
182
169
|
sep = os.path.sep
|
|
183
170
|
if sep not in path: sep = '/' # try internal posix style
|
|
@@ -1131,11 +1118,11 @@ def unique(seq, idfun=None):
|
|
|
1131
1118
|
|
|
1132
1119
|
|
|
1133
1120
|
def get_builtin_template_transaction_csv():
|
|
1134
|
-
return get_resource_as_string('resources.jinja', 'builtin_transactions_csv.j2').strip()
|
|
1121
|
+
return resources.get_resource_as_string('resources.jinja', 'builtin_transactions_csv.j2').strip()
|
|
1135
1122
|
|
|
1136
1123
|
|
|
1137
1124
|
def get_builtin_template_console_summary():
|
|
1138
|
-
return get_resource_as_string('resources.jinja', 'builtin_console_summary.j2').strip()
|
|
1125
|
+
return resources.get_resource_as_string('resources.jinja', 'builtin_console_summary.j2').strip()
|
|
1139
1126
|
|
|
1140
1127
|
|
|
1141
1128
|
def print_extended_help():
|
neoload/commands/validate.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import click
|
|
2
2
|
import neoload_cli_lib.schema_validation as schema_validation
|
|
3
|
-
from neoload_cli_lib.schema_validation import __default_schema_url
|
|
4
3
|
|
|
5
4
|
@click.command()
|
|
6
5
|
@click.option('-s', '--as-code-schema', default=None,
|
|
7
6
|
help="NeoLoad as-code schema (URL or local path) to validate FILE against. "
|
|
8
|
-
"
|
|
7
|
+
"When omitted, download schemas/v<schemaVersion>/as-code.schema.json from neoload-models tag 3.4.22. "
|
|
8
|
+
"If schemaVersion is absent, use schemas/v3.0/as-code.schema.json.",
|
|
9
9
|
metavar="PATH|URL")
|
|
10
10
|
@click.option('--schema-url', 'schema_url', default=None, hidden=True,
|
|
11
11
|
help="Deprecated alias for --as-code-schema, kept for backward compatibility.")
|
|
@@ -15,5 +15,5 @@ from neoload_cli_lib.schema_validation import __default_schema_url
|
|
|
15
15
|
def cli(file, refresh, as_code_schema, schema_url, ssl_cert):
|
|
16
16
|
"""Verify that the yaml FILE matches the neoload as-code file format"""
|
|
17
17
|
# -s/--as-code-schema (new) takes priority over --schema-url (deprecated alias)
|
|
18
|
-
resolved_schema = as_code_schema or schema_url
|
|
18
|
+
resolved_schema = as_code_schema or schema_url
|
|
19
19
|
print(schema_validation.validate_path(file, resolved_schema, ssl_cert))
|