Files
deb-python-dcos/cli/tests/integrations/test_cluster.py
tamarrow 63bcddaa20 cluster: add subcommand for easy setup of multiple clusters (#983)
We are introducing a new subcommand for managing your clusters. Configuring your CLI to talk to your cluster is a single command now `dcos cluster setup`. Moreover, the CLI can now be aware of multiple clusters with cluster specific configuration managed by the CLI. 

Subcommands will be installed for the current "attached" cluster only. To install a subcommand for all your configured clusters, use `--global`. 

Note that `DCOS_CONFIG` environment variable will not take effect in
"cluster" mode since we are now managing different clusters in the CLI.
2017-05-03 10:41:45 -07:00

46 lines
1.3 KiB
Python

import json
from .helpers.common import assert_command, exec_command
def test_info():
stdout = b'Manage your DC/OS clusters\n'
assert_command(['dcos', 'cluster', '--info'],
stdout=stdout)
def test_version():
stdout = b'dcos-cluster version SNAPSHOT\n'
assert_command(['dcos', 'cluster', '--version'],
stdout=stdout)
def test_list():
returncode, stdout, stderr = exec_command(
['dcos', 'cluster', 'list', '--json'])
assert returncode == 0
assert stderr == b''
cluster_list = json.loads(stdout.decode('utf-8'))
assert len(cluster_list) == 1
info = cluster_list[0]
assert info.get("attached")
keys = ["attached", "cluster_id", "name", "url", "version"]
assert sorted(info.keys()) == keys
def test_rename():
_, stdout, _ = exec_command(
['dcos', 'cluster', 'list', '--json'])
info = json.loads(stdout.decode('utf-8'))[0]
name = info.get("name")
new_name = "test"
assert_command(['dcos', 'cluster', 'rename', name, new_name])
returncode, stdout, stderr = exec_command(
['dcos', 'cluster', 'list', '--json'])
assert json.loads(stdout.decode('utf-8'))[0].get("name") == new_name
# rename back to original name
assert_command(['dcos', 'cluster', 'rename', new_name, name])