Skip to content
Open
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
47 changes: 36 additions & 11 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
name: test-hdxcli
run-name: ${{ github.actor }} acceptance tests
on: [push]
run-name: ${{ github.actor }} tests
on:
push:
workflow_dispatch:
inputs:
acceptance:
description: "Also run the live-cluster acceptance suite (tests/command_line_interface)"
type: boolean
default: false
jobs:
run-tests:
# Hermetic unit tests. These cover the maintained surface (the migrate command and its
# helpers) and need no cluster, so they run on every push.
unit-tests:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4.3.0
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: "Install poetry"
run: python3 -m pip install poetry==2.0.1
- name: "Install hdxcli dependencies"
run: python3 -m poetry install
- name: "Set environment for tests"
run: |
echo "PYTHONPATH=$GITHUB_WORKSPACE/src" >> $GITHUB_ENV
- name: "Run tests"
run: poetry run python3 -m pytest -v
- name: "Run unit tests"
run: poetry run python3 -m pytest -v tests --ignore=tests/command_line_interface
env:
PYTHONPATH: ${{ github.workspace }}/src

# Live-cluster acceptance suite for the legacy CRUD commands. It requires the
# HDXCLI_TESTS_CLUSTER_* secrets and a reachable cluster, so it only runs on demand.
acceptance-tests:
if: github.event_name == 'workflow_dispatch' && inputs.acceptance
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: "Install poetry"
run: python3 -m pip install poetry==2.0.1
- name: "Install hdxcli dependencies"
run: python3 -m poetry install
- name: "Run acceptance tests"
run: poetry run python3 -m pytest -v tests/command_line_interface
env:
PYTHONPATH: ${{ github.workspace }}/src
HDXCLI_TESTS_CLUSTER_SSL_ACTIVE: ${{secrets.HDXCLI_TESTS_CLUSTER_SSL_ACTIVE}}
HDXCLI_TESTS_CLUSTER_PASSWORD: ${{secrets.HDXCLI_TESTS_CLUSTER_PASSWORD}}
HDXCLI_TESTS_CLUSTER_USERNAME: ${{secrets.HDXCLI_TESTS_CLUSTER_USERNAME}}
PYTHONPATH: ${{env.PYTHONPATH}}
HDXCLI_TESTS_CLUSTER_HOSTNAME: ${{secrets.HDXCLI_TESTS_CLUSTER_HOSTNAME}}
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
version = "1.0.83"
version = "1.0.84"
name = "hdxcli"
requires-python = ">=3.10,<4.0"
maintainers = [
Expand All @@ -10,7 +10,7 @@ maintainers = [

[tool.poetry]
name = "hdxcli"
version = "1.0.83"
version = "1.0.84"
description = "Hydrolix command line utility to do CRUD operations on projects, tables, transforms and other resources in Hydrolix clusters"
authors = ["German Diago Gomez <german@hydrolix.io>", "Agustin Actis <agustin@hydrolix.io>"]
license = "Apache-2.0"
Expand Down
25 changes: 21 additions & 4 deletions src/hdx_cli/cli_interface/migrate/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from hdx_cli.cli_interface.migrate.data import migrate_data
from hdx_cli.cli_interface.migrate.helpers import MigrationData, get_catalog
from hdx_cli.cli_interface.migrate.rc.rc_manager import RcloneAPIConfig
from hdx_cli.cli_interface.migrate.resources import get_resources, create_resources
from hdx_cli.cli_interface.migrate.resources import create_resources, get_resources
from hdx_cli.cli_interface.migrate.validator import validations
from hdx_cli.config.profile_settings import is_valid_hostname
from hdx_cli.library_api.common.exceptions import InvalidHostnameException
from hdx_cli.library_api.common.logging import get_logger
from hdx_cli.library_api.utility.decorators import report_error_and_exit, ensure_logged_in
from hdx_cli.library_api.utility.decorators import ensure_logged_in, report_error_and_exit

logger = get_logger()

Expand Down Expand Up @@ -79,6 +79,14 @@ def validate_hostname(ctx, params, hostname: str) -> str:
type=click.Choice(["http", "https"], case_sensitive=False),
help="URI scheme for the target cluster (http or https).",
)
@click.option(
"--target-customer",
"-tc",
"target_customer",
default=None,
help="Name or UUID of the customer on the target cluster to assign to the migrated "
"project. Required by clusters v6.3+; if omitted, you are prompted to choose one.",
)
@click.option(
"--allow-merge",
type=bool,
Expand Down Expand Up @@ -169,6 +177,7 @@ def migrate(
target_username: str,
target_password: str,
target_uri_scheme: str,
target_customer: str,
allow_merge: bool,
only: str,
with_functions: bool,
Expand Down Expand Up @@ -205,6 +214,11 @@ def migrate(
- Target Cluster: Specify the destination with `--target-profile` or with individual
connection details (`--target-hostname`, `--target-username`, etc.).
\b
- Target Customer (`--target-customer`): Clusters v6.3+ require every project to
belong to a customer. Provide the target customer by name or UUID; when omitted,
the command lists the target's customers and prompts for one, offering to create
it if it does not exist.
\b
- Migration Scope (`--only`):
- *resources*: Migrates only the project, table, and other definitions.
- *data*: Migrates only the data, assuming resources already exist.
Expand Down Expand Up @@ -239,7 +253,9 @@ def migrate(
"""
source_profile = ctx.parent.obj["usercontext"]
has_target_profile = target_profile_name is not None
has_all_cluster_options = all([target_hostname, target_username, target_password, target_uri_scheme])
has_all_cluster_options = all(
[target_hostname, target_username, target_password, target_uri_scheme]
)

if not has_target_profile and not has_all_cluster_options:
raise click.BadParameter(
Expand Down Expand Up @@ -320,7 +336,8 @@ def migrate(
source_data,
reuse_partitions,
migrate_functions=with_functions,
migrate_dictionaries=with_dictionaries
migrate_dictionaries=with_dictionaries,
target_customer=target_customer,
)
if only != "resources":
migrate_data(
Expand Down
Loading