Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ oci-env -e custom.env compose up
### Lint

```bash
# Install the lint requirements and run the linter for a specific plugin

oci-env test -i -p PLUGIN_NAME lint

# Run the linter without installing lint dependencies.
# Install lint requirements and run the linter for a specific plugin
oci-env test -p PLUGIN_NAME lint
```

Expand All @@ -74,13 +70,10 @@ Ex:
```

```bash
# Generate the pulp client. This will build clients for all plugins in DEV_SOURCE_PATH. -i will also install the client in the container.
oci-env generate-client -i
# Generate and install clients for all plugins in DEV_SOURCE_PATH.
oci-env generate-client

# Install the functional test requirements and run the tests
oci-env test -i -p PLUGIN_NAME functional

# Run the tests without installing dependencies.
# Install functional test requirements and run the tests
oci-env test -p PLUGIN_NAME functional
```

Expand All @@ -93,7 +86,7 @@ e.g. `oci-env generate-client -l ruby PLUGIN_NAME`.

1. Add "epdb" to the functest_requirements.txt file in your pulp_ansible checkout path.
2. Inside any functional test, add `import epdb; epdb.st()`.
3. Re-run `oci-env test -i functional` and `oci-env test -p pulp_ansible functional --capture=no` commands again.
3. Re-run `oci-env test -p pulp_ansible functional --capture=no`.

#### Using PyCharm remote debug server

Expand Down Expand Up @@ -123,10 +116,7 @@ The docs are served on the URL logged by the `make servedocs` step.
### Unit

```bash
# Install the unit test dependencies for a plugin and run it.
oci-env test -i -p PLUGIN_NAME unit

# Run the unit tests for a plugin without installing test dependencies.
# Install unit test dependencies and run them for a plugin.
oci-env test -p PLUGIN_NAME unit
```

Expand Down
13 changes: 5 additions & 8 deletions base/container_scripts/run_functional_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ function check_pytest () {

ERROR: pytest is not installed

This usually means you did not include the "-i" flag with the oci-env "test"
subcommand. The first invocation of functional tests needs "-i" to install the
test requirements (inc. pytest). After the requirements are installed, "-i" can
be dropped from further runs on the same container instance.
This usually means the functional test requirements failed to install. Check that
functest_requirements.txt exists for the plugin and that "oci-env test -p PLUGIN
functional" completed the install step successfully.
EOF
exit 1
}
Expand All @@ -33,10 +32,8 @@ function check_client () {

ERROR: pulpcore.client.${PROJECT} is missing.

This usually means you did not run "oci-env generate-client -i ${PROJECT}" before
running the functional test command. It could also mean you did not pass the "-i"
flag to the "generate-client" subcommand which would have created the client, but
not install it into the appropriate location.
This usually means you did not run "oci-env generate-client ${PROJECT}" before
running the functional test command.
EOF
exit 1
}
Expand Down
13 changes: 5 additions & 8 deletions base/container_scripts/run_performance_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ function check_pytest () {

ERROR: pytest is not installed

This usually means you did not include the "-i" flag with the oci-env "test"
subcommand. The first invocation of functional tests needs "-i" to install the
test requirements (inc. pytest). After the requirements are installed, "-i" can
be dropped from further runs on the same container instance.
This usually means the performance test requirements failed to install. Check that
perftest_requirements.txt or functest_requirements.txt exists for the plugin and
that "oci-env test -p PLUGIN performance" completed the install step successfully.
EOF
exit 1
}
Expand All @@ -32,10 +31,8 @@ function check_client () {

ERROR: pulpcore.client.${PROJECT} is missing.

This usually means you did not run "oci-env generate-client -i ${PROJECT}" before
running the functional test command. It could also mean you did not pass the "-i"
flag to the "generate-client" subcommand which would have created the client, but
not install it into the appropriate location.
This usually means you did not run "oci-env generate-client ${PROJECT}" before
running the performance test command.
EOF
exit 1
}
Expand Down
33 changes: 18 additions & 15 deletions client/oci_env/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,25 @@ def shell(args, client):


def test(args, client):
if args.install_deps:
test_script = f"install_{args.test}_requirements.sh"
test_script = f"install_{args.test}_requirements.sh"

if args.plugin:
if args.plugin:
exit_if_failed(
client.exec_container_script(
test_script,
args=[args.plugin],
privileged=args.privileged,
).returncode
)
else:
for project in client.config["DEV_SOURCE_PATH"].split(":"):
exit_if_failed(
client.exec_container_script(
test_script,
args=[args.plugin],
args=[project],
privileged=args.privileged,
).returncode
)
else:
for project in client.config["DEV_SOURCE_PATH"].split(":"):
exit_if_failed(
client.exec_container_script(
test_script,
args=[project],
privileged=args.privileged,
).returncode
)

if args.plugin:
exit_if_failed(
Expand Down Expand Up @@ -122,8 +121,12 @@ def generate_client(args, client):

exit_if_failed(subprocess.run(cmd, env=env, cwd=client.path).returncode)

if args.install_client:
exit_if_failed(client.exec_container_script("install_client.sh", args=[plugin.replace("-", "_")]).returncode)
if args.language == "python":
exit_if_failed(
client.exec_container_script(
"install_client.sh", args=[plugin.replace("-", "_")]
).returncode
)


def pulpcore_manager(args, client):
Expand Down
6 changes: 3 additions & 3 deletions client/oci_env/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def parse_shell_command(subparsers):
def parse_test_command(subparsers):
parser = subparsers.add_parser('test', help='Run tests and install requirements.')
parser.add_argument('test', choices=["functional", "unit", "lint", "performance"])
parser.add_argument('-i', action='store_true', dest='install_deps', help="Install the python dependencies for the selected test instead of running it. If -p is not specified this will install all the test dependencies for each plugin in DEV_SOURCE_PATH.")
parser.add_argument('-i', action='store_true', dest='install_deps', help="Deprecated no-op. Test dependencies are always installed.")
parser.add_argument('-p', type=str, default="", dest='plugin', help="Plugin to test. Tests won't run unless this is specified.")
parser.add_argument('args', nargs=argparse.REMAINDER, help='Arguments to pass to pytest.')
parser.add_argument('args', nargs=argparse.REMAINDER, help='Arguments to pass to pytest. Use -k/-m to select tests (file paths are not supported with --pyargs).')
parser.add_argument("--privileged", action="store_true", dest="privileged")
parser.set_defaults(func=test)

Expand All @@ -112,7 +112,7 @@ def parse_generate_client_command(subparsers):
parser = subparsers.add_parser('generate-client', help='Generate the the pulp client.')
parser.add_argument('plugin', nargs="?", default=None, help="Plugin to generate a client for. If no plugin is specified clients will be generated for all plugins in DEV_SOURCE_PATH.")
parser.add_argument('-l', '--language', default="python", choices=['python', 'ruby'], help="Language to generate a client for. If no language is specified clients will be generated for python.")
parser.add_argument('-i', action='store_true', dest='install_client', help="Install the client after generating it.")
parser.add_argument('-i', action='store_true', dest='install_client', help="Deprecated no-op. Python clients are always installed after generating.")

parser.set_defaults(func=generate_client)

Expand Down
21 changes: 6 additions & 15 deletions docs/dev/guides/run-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
## Lint

```bash
# Install the lint requirements and run the linter for a specific plugin
oci-env test -i -p PLUGIN_NAME lint

# Run the linter without installing lint dependencies.
# Install lint requirements and run the linter for a specific plugin
oci-env test -p PLUGIN_NAME lint
```

## Unit

```bash
# Install the unit test dependencies for a plugin and run it.
oci-env test -i -p PLUGIN_NAME unit

# Run the unit tests for a plugin without installing test dependencies.
# Install unit test dependencies and run them for a plugin.
oci-env test -p PLUGIN_NAME unit
```

Expand All @@ -32,13 +26,10 @@ Before functional tests can be run, you must clone `github.com/pulp/pulp-openapi
```

```bash
# Generate the pulp client. This will build clients for all plugins in DEV_SOURCE_PATH. -i will also install the client in the container.
oci-env generate-client -i

# Install the functional test requirements and run the tests
oci-env test -i -p PLUGIN_NAME functional
# Generate and install clients for all plugins in DEV_SOURCE_PATH.
oci-env generate-client

# Run the tests without installing dependencies.
# Install functional test requirements and run the tests
oci-env test -p PLUGIN_NAME functional
```

Expand All @@ -53,7 +44,7 @@ e.g. `oci-env generate-client -l ruby PLUGIN_NAME`.

1. Add "epdb" to the `functest_requirements.txt` file in your pulp_ansible checkout path.
2. Inside any functional test, add `import epdb; epdb.st()`.
3. Re-run `oci-env test -i functional` and `oci-env test -p pulp_ansible functional --capture=no` commands again.
3. Re-run `oci-env test -p pulp_ansible functional --capture=no`.

### Using PyCharm

Expand Down
Loading