vantage6 5.0.0a41__tar.gz → 5.0.0a42__tar.gz

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.

Potentially problematic release.


This version of vantage6 might be problematic. Click here for more details.

Files changed (111) hide show
  1. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/PKG-INFO +3 -3
  2. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/pyproject.toml +3 -3
  3. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/tests_cli/test_node_cli.py +107 -142
  4. vantage6-5.0.0a42/tests_cli/test_server_cli.py +263 -0
  5. vantage6-5.0.0a42/tests_cli/test_wizard.py +174 -0
  6. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/common/list.py +3 -3
  7. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/common/new.py +5 -7
  8. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/common/start.py +10 -93
  9. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/common/utils.py +0 -107
  10. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/configuration_create.py +1 -0
  11. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/context/algorithm_store.py +1 -13
  12. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/context/node.py +1 -38
  13. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/context/server.py +1 -13
  14. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/attach.py +1 -1
  15. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/common/__init__.py +1 -23
  16. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/files.py +3 -3
  17. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/new.py +0 -3
  18. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/remove.py +1 -1
  19. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/start.py +39 -43
  20. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/config/node.py +2 -5
  21. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/remove.py +8 -1
  22. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/attach.py +1 -1
  23. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/template/node_config.j2 +9 -1
  24. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/template/node_config_nonk8s.j2 +0 -4
  25. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/test/integration_test.py +2 -2
  26. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/utils.py +0 -17
  27. vantage6-5.0.0a41/tests_cli/test_server_cli.py +0 -180
  28. vantage6-5.0.0a41/tests_cli/test_wizard.py +0 -141
  29. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/.gitignore +0 -0
  30. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/Makefile +0 -0
  31. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/README.md +0 -0
  32. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/tests_cli/__init__.py +0 -0
  33. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/tests_cli/test_client_script.py +0 -0
  34. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/tests_cli/test_example.py +0 -0
  35. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/__init__.py +0 -0
  36. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algorithm/create.py +0 -0
  37. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algorithm/generate_algorithm_json.py +0 -0
  38. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algorithm/update.py +0 -0
  39. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algostore/attach.py +0 -0
  40. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algostore/files.py +0 -0
  41. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algostore/list.py +0 -0
  42. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algostore/new.py +0 -0
  43. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algostore/remove.py +0 -0
  44. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algostore/start.py +0 -0
  45. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algostore/stop.py +0 -0
  46. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/algostore/version.py +0 -0
  47. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/auth/attach.py +0 -0
  48. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/auth/files.py +0 -0
  49. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/auth/list.py +0 -0
  50. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/auth/new.py +0 -0
  51. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/auth/remove.py +0 -0
  52. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/auth/start.py +0 -0
  53. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/auth/stop.py +0 -0
  54. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/cli.py +0 -0
  55. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/common/attach.py +0 -0
  56. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/common/decorator.py +0 -0
  57. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/common/remove.py +0 -0
  58. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/common/stop.py +0 -0
  59. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/common/version.py +0 -0
  60. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/config.py +0 -0
  61. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/configuration_manager.py +0 -0
  62. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/context/__init__.py +0 -0
  63. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/context/auth.py +0 -0
  64. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/context/base_server.py +0 -0
  65. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/dev/clean.py +0 -0
  66. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/dev/common.py +0 -0
  67. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/dev/rebuild.py +0 -0
  68. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/dev/start.py +0 -0
  69. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/dev/stop.py +0 -0
  70. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/globals.py +0 -0
  71. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/common/task_cleanup.py +0 -0
  72. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/create_private_key.py +0 -0
  73. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/list.py +0 -0
  74. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/restart.py +0 -0
  75. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/set_api_key.py +0 -0
  76. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/stop.py +0 -0
  77. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/node/version.py +0 -0
  78. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/prometheus/monitoring_manager.py +0 -0
  79. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/prometheus/prometheus.yml +0 -0
  80. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/config/base.py +0 -0
  81. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/config/core.py +0 -0
  82. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/data/km_dataset.csv +0 -0
  83. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/data/olympic_athletes_2016.csv +0 -0
  84. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/new.py +0 -0
  85. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/populate/__init__.py +0 -0
  86. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/populate/helpers/connect_store.py +0 -0
  87. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/populate/helpers/delete_fixtures.py +0 -0
  88. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/populate/helpers/load_fixtures.py +0 -0
  89. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/populate/helpers/utils.py +0 -0
  90. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/start.py +0 -0
  91. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/sandbox/stop.py +0 -0
  92. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/common/__init__.py +0 -0
  93. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/files.py +0 -0
  94. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/import_.py +0 -0
  95. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/list.py +0 -0
  96. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/new.py +0 -0
  97. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/remove.py +0 -0
  98. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/start.py +0 -0
  99. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/stop.py +0 -0
  100. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/server/version.py +0 -0
  101. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/template/algo_store_config.j2 +0 -0
  102. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/template/auth_config.j2 +0 -0
  103. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/template/server_config.j2 +0 -0
  104. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/test/algo_test_scripts/algo_test_arguments.py +0 -0
  105. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/test/algo_test_scripts/algo_test_script.py +0 -0
  106. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/test/client_script.py +0 -0
  107. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/test/common/diagnostic_runner.py +0 -0
  108. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/test/feature_tester.py +0 -0
  109. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/use/context.py +0 -0
  110. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/use/namespace.py +0 -0
  111. {vantage6-5.0.0a41 → vantage6-5.0.0a42}/vantage6/cli/utils_kubernetes.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vantage6
3
- Version: 5.0.0a41
3
+ Version: 5.0.0a42
4
4
  Summary: vantage6 command line interface
5
5
  Author: Vantage6 Team
6
6
  Maintainer-email: Frank Martin <f.martin@iknl.nl>, Bart van Beusekom <b.vanbeusekom@iknl.nl>
@@ -18,8 +18,8 @@ Requires-Dist: questionary==2.1.1
18
18
  Requires-Dist: rich==13.5.2
19
19
  Requires-Dist: schema==0.7.5
20
20
  Requires-Dist: sqlalchemy==2.0.37
21
- Requires-Dist: vantage6-client==5.0.0a41
22
- Requires-Dist: vantage6-common==5.0.0a41
21
+ Requires-Dist: vantage6-client==5.0.0a42
22
+ Requires-Dist: vantage6-common==5.0.0a42
23
23
  Provides-Extra: dev
24
24
  Requires-Dist: black; extra == 'dev'
25
25
  Requires-Dist: coverage==7.10.2; extra == 'dev'
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "vantage6"
7
- version = "5.0.0a41"
7
+ version = "5.0.0a42"
8
8
  description = "vantage6 command line interface"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -29,8 +29,8 @@ dependencies = [
29
29
  "rich==13.5.2",
30
30
  "schema==0.7.5",
31
31
  "sqlalchemy==2.0.37",
32
- "vantage6-common==5.0.0a41",
33
- "vantage6-client==5.0.0a41",
32
+ "vantage6-common==5.0.0a42",
33
+ "vantage6-client==5.0.0a42",
34
34
  ]
35
35
 
36
36
  [project.optional-dependencies]
@@ -1,18 +1,13 @@
1
- import contextlib
2
- import logging
3
1
  import os
4
2
  import unittest
5
- from io import BytesIO, StringIO
6
3
  from pathlib import Path
7
4
  from unittest.mock import MagicMock, patch
8
5
 
9
6
  from click.testing import CliRunner
10
7
 
11
- from vantage6.common import STRING_ENCODING
12
- from vantage6.common.globals import LOCALHOST, Ports
8
+ from vantage6.common.globals import LOCALHOST, InstanceType, Ports
13
9
 
14
- from vantage6.cli.common.utils import print_log_worker
15
- from vantage6.cli.globals import APPNAME
10
+ from vantage6.cli.globals import APPNAME, InfraComponentName
16
11
  from vantage6.cli.node.attach import cli_node_attach
17
12
  from vantage6.cli.node.common import create_client_and_authenticate
18
13
  from vantage6.cli.node.create_private_key import cli_node_create_private_key
@@ -27,39 +22,21 @@ from vantage6.cli.node.stop import cli_node_stop
27
22
  class NodeCLITest(unittest.TestCase):
28
23
  @classmethod
29
24
  def setUpClass(cls):
30
- logging.getLogger("docker.utils.config").setLevel(logging.WARNING)
31
25
  return super().setUpClass()
32
26
 
33
- @patch("docker.DockerClient.ping")
34
- def test_list_docker_not_running(self, docker_ping):
35
- """An error is printed when docker is not running"""
36
- docker_ping.side_effect = Exception("Boom!")
37
-
38
- runner = CliRunner()
39
- result = runner.invoke(cli_node_list, [])
40
-
41
- # check exit code
42
- self.assertEqual(result.exit_code, 1)
43
-
44
27
  @patch("vantage6.cli.context.node.NodeContext.available_configurations")
45
- @patch("docker.DockerClient.ping")
46
- @patch("docker.DockerClient.containers")
47
- def test_list(self, containers, docker_ping, available_configurations):
28
+ @patch("vantage6.cli.common.list.find_running_service_names")
29
+ def test_list(self, find_running_service_names, available_configurations):
48
30
  """A container list and their current status."""
49
31
  # https://docs.python.org/3/library/unittest.mock.html#mock-names-and-the-name-attribute
50
32
 
51
- # mock that docker-deamon is running
52
- docker_ping.return_value = True
53
-
54
- # docker deamon returns a list of running node-containers
55
- container1 = MagicMock()
56
- container1.name = f"{APPNAME}-iknl-user"
57
- containers.list.return_value = [container1]
33
+ node_name = "iknl"
34
+ find_running_service_names.return_value = [f"{APPNAME}-{node_name}-user-node"]
58
35
 
59
36
  # returns a list of configurations and failed inports
60
37
  def side_effect(system_folders):
61
38
  config = MagicMock()
62
- config.name = "iknl"
39
+ config.name = node_name
63
40
  if not system_folders:
64
41
  return [[config], []]
65
42
  else:
@@ -84,14 +61,16 @@ class NodeCLITest(unittest.TestCase):
84
61
  "-----------------------------------------------------\n",
85
62
  )
86
63
 
87
- @patch("vantage6.cli.node.new.make_configuration")
88
- @patch("vantage6.cli.node.new.ensure_config_dir_writable")
64
+ @patch("vantage6.cli.common.new.select_context_and_namespace")
65
+ @patch("vantage6.cli.common.new.make_configuration")
66
+ @patch("vantage6.cli.common.new.ensure_config_dir_writable")
89
67
  @patch("vantage6.cli.node.common.NodeContext")
90
- def test_new_config(self, context, permissions, make_configuration):
68
+ def test_new_config(self, context, permissions, make_configuration, ctx_ns):
91
69
  """No error produced when creating new configuration."""
92
70
  context.config_exists.return_value = False
93
71
  permissions.return_value = True
94
72
  make_configuration.return_value = "/some/file/path"
73
+ ctx_ns.return_value = ("test-context", "test-namespace")
95
74
 
96
75
  runner = CliRunner()
97
76
  result = runner.invoke(
@@ -108,7 +87,7 @@ class NodeCLITest(unittest.TestCase):
108
87
  # check OK exit code
109
88
  self.assertEqual(result.exit_code, 0)
110
89
 
111
- @patch("vantage6.cli.node.new.make_configuration")
90
+ @patch("vantage6.cli.common.new.make_configuration")
112
91
  def test_new_config_replace_whitespace_in_name(self, make_configuration):
113
92
  """Whitespaces are replaced in the name."""
114
93
 
@@ -121,16 +100,17 @@ class NodeCLITest(unittest.TestCase):
121
100
  ],
122
101
  )
123
102
 
124
- self.assertEqual(
125
- result.output[:60],
126
- "[info ] - Replaced spaces from configuration name: some-name",
127
- )
103
+ self.assertTrue("[error] - Invalid name: 'some name'." in result.output)
104
+ self.assertEqual(result.exit_code, 1)
128
105
 
129
- @patch("vantage6.cli.node.new.NodeContext")
130
- def test_new_config_already_exists(self, context):
106
+ # the context is mocked for select_context_class where it is instantiated
107
+ @patch("vantage6.cli.common.new.select_context_and_namespace")
108
+ @patch("vantage6.cli.context.NodeContext")
109
+ def test_new_config_already_exists(self, context, ctx_ns):
131
110
  """No duplicate configurations are allowed."""
132
111
 
133
112
  context.config_exists.return_value = True
113
+ ctx_ns.return_value = ("test-context", "test-namespace")
134
114
 
135
115
  runner = CliRunner()
136
116
  result = runner.invoke(
@@ -142,18 +122,22 @@ class NodeCLITest(unittest.TestCase):
142
122
  )
143
123
 
144
124
  # check that error is produced
145
- self.assertEqual(result.output[:7], "[error]")
125
+ self.assertIn(
126
+ "[error] - Configuration some-name already exists!", result.output
127
+ )
146
128
 
147
129
  # check non-zero exit code
148
130
  self.assertEqual(result.exit_code, 1)
149
131
 
150
- @patch("vantage6.cli.node.new.ensure_config_dir_writable")
132
+ @patch("vantage6.cli.common.new.select_context_and_namespace")
133
+ @patch("vantage6.cli.common.new.ensure_config_dir_writable")
151
134
  @patch("vantage6.cli.node.common.NodeContext")
152
- def test_new_write_permissions(self, context, permissions):
135
+ def test_new_write_permissions(self, context, permissions, ctx_ns):
153
136
  """User needs write permissions."""
154
137
 
155
138
  context.config_exists.return_value = False
156
139
  permissions.return_value = False
140
+ ctx_ns.return_value = ("test-context", "test-namespace")
157
141
 
158
142
  runner = CliRunner()
159
143
  result = runner.invoke(
@@ -165,18 +149,16 @@ class NodeCLITest(unittest.TestCase):
165
149
  )
166
150
 
167
151
  # check that error is produced
168
- self.assertEqual(result.output[:7], "[error]")
152
+ self.assertTrue("[error] - Your user does not have write" in result.output)
169
153
 
170
154
  # check non-zero exit code
171
155
  self.assertEqual(result.exit_code, 1)
172
156
 
173
- @patch("vantage6.cli.node.common.NodeContext")
174
- @patch("vantage6.cli.node.files.NodeContext")
175
- @patch("vantage6.cli.node.common.select_configuration_questionnaire")
176
- def test_files(self, select_config, context, common_context):
157
+ @patch("vantage6.cli.common.decorator.get_context")
158
+ @patch("vantage6.cli.common.decorator.select_configuration_questionnaire")
159
+ def test_files(self, select_config, context):
177
160
  """No errors produced when retrieving filepaths."""
178
161
 
179
- common_context.config_exists.return_value = True
180
162
  context.return_value = MagicMock(
181
163
  config_file="/file.yaml", log_file="/log.log", data_dir="/dir"
182
164
  )
@@ -207,99 +189,102 @@ class NodeCLITest(unittest.TestCase):
207
189
  # check for non zero exit-code
208
190
  self.assertNotEqual(result.exit_code, 0)
209
191
 
210
- @patch("docker.DockerClient.volumes")
211
- @patch("vantage6.cli.node.start.pull_infra_image")
192
+ @patch("vantage6.cli.node.start.select_context_and_namespace")
193
+ @patch("os.makedirs")
212
194
  @patch("vantage6.cli.common.decorator.get_context")
213
- @patch("docker.DockerClient.containers")
214
- @patch("vantage6.cli.node.start.check_docker_running", return_value=True)
215
- def test_start(self, check_docker, client, context, pull, volumes):
216
- # client.containers = MagicMock(name="docker.DockerClient.containers")
217
- client.list.return_value = []
218
- volume = MagicMock()
219
- volume.name = "data-vol-name"
220
- volumes.create.return_value = volume
221
- context.config_exists.return_value = True
195
+ @patch("vantage6.cli.node.start.helm_install")
196
+ @patch("vantage6.cli.node.start.start_port_forward")
197
+ def test_start(
198
+ self,
199
+ start_port_forward,
200
+ helm_install,
201
+ context,
202
+ os_makedirs,
203
+ ctx_ns,
204
+ ):
205
+ """Start node without errors"""
222
206
 
223
207
  ctx = MagicMock(
224
- data_dir=Path("data"),
225
- log_dir=Path("logs"),
226
- config_dir=Path("configs"),
227
- databases=[{"label": "some_label", "uri": "data.csv", "type": "csv"}],
208
+ config={"node": {"proxyPort": 8080, "image": "my-node-image"}},
209
+ config_file="/config.yaml",
210
+ data_dir=Path("."),
211
+ log_dir=Path("."),
212
+ helm_release_name="vantage6-test-node",
213
+ is_sandbox=False,
228
214
  )
229
-
230
- # cli_node_start() tests for truth value of a set-like object derived
231
- # from ctx.config.get('node_extra_env', {}). Default MagicMock() will
232
- # evaluate to True, empty dict to False. False signifies no overwritten
233
- # env vars, hence no error.
234
- def config_get_side_effect(key, default=None):
235
- if key == "node_extra_env":
236
- return {}
237
- return MagicMock()
238
-
239
- ctx.config.get.side_effect = config_get_side_effect
240
- ctx.get_data_file.return_value = "data.csv"
241
- ctx.name = "some-name"
215
+ ctx.config_exists.return_value = True
216
+ ctx.name = "test-node"
242
217
  context.return_value = ctx
218
+ ctx_ns.return_value = ("test-context", "test-namespace")
243
219
 
244
220
  runner = CliRunner()
221
+ result = runner.invoke(cli_node_start, ["--name", "test-node"])
245
222
 
246
- # Should fail when starting node with non-existing database CSV file
247
- with runner.isolated_filesystem():
248
- result = runner.invoke(cli_node_start, ["--name", "some-name"])
249
- self.assertEqual(result.exit_code, 1)
250
-
251
- # now do it with a SQL database which doesn't have to be an existing file
252
- ctx.databases = [{"label": "some_label", "uri": "data.db", "type": "sql"}]
253
- with runner.isolated_filesystem():
254
- result = runner.invoke(cli_node_start, ["--name", "some-name"])
255
223
  self.assertEqual(result.exit_code, 0)
256
224
 
257
- def _setup_stop_test(self, containers):
258
- container1 = MagicMock()
259
- container1.name = f"{APPNAME}-iknl-user"
260
- containers.list.return_value = [container1]
261
-
262
- @patch("docker.DockerClient.containers")
263
- @patch("vantage6.cli.node.stop.check_docker_running", return_value=True)
264
- @patch("vantage6.cli.node.stop.NodeContext")
265
- @patch("vantage6.cli.node.stop.delete_volume_if_exists")
266
- def test_stop(self, delete_volume, node_context, check_docker, containers):
267
- self._setup_stop_test(containers)
225
+ @patch("vantage6.cli.common.stop.select_context_and_namespace")
226
+ @patch("vantage6.cli.common.stop.get_context")
227
+ @patch("vantage6.cli.common.utils.find_running_service_names")
228
+ @patch("vantage6.cli.node.stop._stop_node")
229
+ def test_stop(self, _stop_node, find_running_service_names, get_context, ctx_ns):
230
+ node_name = "iknl"
231
+ node_helm_name = f"{APPNAME}-{node_name}-user-node"
232
+ find_running_service_names.return_value = [node_helm_name]
233
+ get_context.return_value = MagicMock(helm_release_name=node_helm_name)
234
+ ctx_ns.return_value = ("test-context", "test-namespace")
268
235
 
269
236
  runner = CliRunner()
270
-
271
237
  result = runner.invoke(cli_node_stop, ["--name", "iknl"])
272
238
 
273
- self.assertEqual(
274
- result.output, "[info ] - Stopped the vantage6-iknl-user Node.\n"
275
- )
276
-
277
239
  self.assertEqual(result.exit_code, 0)
240
+ self.assertIsNone(result.exception)
278
241
 
279
- @patch("docker.DockerClient.containers")
280
- @patch("vantage6.cli.node.stop.check_docker_running", return_value=True)
281
- @patch("vantage6.cli.node.stop.NodeContext")
282
- @patch("vantage6.cli.node.stop.delete_volume_if_exists")
242
+ @patch("vantage6.cli.common.stop.select_context_and_namespace")
243
+ @patch("vantage6.cli.node.restart.select_context_and_namespace")
283
244
  @patch("vantage6.cli.node.restart.subprocess.run")
245
+ @patch("vantage6.cli.common.stop.get_context")
246
+ @patch("vantage6.cli.node.stop._stop_node")
284
247
  def test_restart(
285
- self, subprocess_run, delete_volume, node_context, check_docker, containers
248
+ self, _stop_node, get_context, subprocess_run, ctx_ns_stop, ctx_ns_restart
286
249
  ):
287
250
  """Restart a node without errors."""
288
- self._setup_stop_test(containers)
289
- # The subprocess.run() function is called with the command to start the node.
290
- # Unfortunately it is hard to test this, so we just return a successful run
291
- subprocess_run.return_value = MagicMock(returncode=0)
251
+ node_name = "iknl"
252
+ node_helm_name = f"{APPNAME}-{node_name}-user-node"
253
+ get_context.return_value = MagicMock(helm_release_name=node_helm_name)
254
+ ctx_ns_stop.return_value = ("test-context", "test-namespace")
255
+ ctx_ns_restart.return_value = ("test-context", "test-namespace")
256
+
257
+ # Mock subprocess.run to handle both helm calls and node start calls
258
+ def mock_subprocess_run(*args, **kwargs):
259
+ # Check if this is a helm command (contains 'helm list')
260
+ if "helm" in args[0] and "list" in args[0]:
261
+ return MagicMock(
262
+ stdout='[{"name": "' + node_helm_name + '", "status": "deployed"}]',
263
+ returncode=0,
264
+ )
265
+ else:
266
+ # For other subprocess calls (like starting the node)
267
+ return MagicMock(returncode=0)
268
+
269
+ subprocess_run.side_effect = mock_subprocess_run
292
270
  runner = CliRunner()
293
- with runner.isolated_filesystem():
294
- result = runner.invoke(cli_node_restart, ["--name", "iknl"])
271
+ result = runner.invoke(cli_node_restart, ["--name", "iknl"])
295
272
  self.assertEqual(result.exit_code, 0)
296
273
 
297
274
  @patch("vantage6.cli.node.attach.attach_logs")
298
275
  def test_attach(self, attach_logs):
299
- """Attach docker logs without errors."""
276
+ """Attach pod logs without errors."""
300
277
  runner = CliRunner()
301
278
  runner.invoke(cli_node_attach)
302
- attach_logs.assert_called_once_with("app=node")
279
+ attach_logs.assert_called_once_with(
280
+ name=None,
281
+ instance_type=InstanceType.NODE,
282
+ infra_component=InfraComponentName.NODE,
283
+ system_folders=False,
284
+ context=None,
285
+ namespace=None,
286
+ is_sandbox=False,
287
+ )
303
288
 
304
289
  @patch("vantage6.cli.node.create_private_key.create_client_and_authenticate")
305
290
  @patch("vantage6.cli.node.common.NodeContext")
@@ -354,8 +339,6 @@ class NodeCLITest(unittest.TestCase):
354
339
  ["--name", "application", "--organization-name", "iknl"],
355
340
  )
356
341
 
357
- # print(result.output)
358
-
359
342
  self.assertEqual(result.exit_code, 0)
360
343
 
361
344
  @patch("vantage6.cli.node.common.NodeContext")
@@ -367,14 +350,6 @@ class NodeCLITest(unittest.TestCase):
367
350
 
368
351
  self.assertEqual(result.exit_code, 1)
369
352
 
370
- def test_print_log_worker(self):
371
- stream = BytesIO("Hello!".encode(STRING_ENCODING))
372
- temp_stdout = StringIO()
373
- with contextlib.redirect_stdout(temp_stdout):
374
- print_log_worker(stream)
375
- output = temp_stdout.getvalue().strip()
376
- self.assertEqual(output, "Hello!")
377
-
378
353
  @patch("vantage6.cli.node.common.info")
379
354
  @patch("vantage6.cli.node.common.debug")
380
355
  @patch("vantage6.cli.node.common.error")
@@ -382,9 +357,13 @@ class NodeCLITest(unittest.TestCase):
382
357
  def test_client(self, client, error, debug, info):
383
358
  ctx = MagicMock(
384
359
  config={
385
- "server_url": LOCALHOST,
386
- "port": Ports.DEV_SERVER.value,
387
- "api_path": "",
360
+ "node": {
361
+ "server": {
362
+ "url": LOCALHOST,
363
+ "port": Ports.DEV_SERVER.value,
364
+ "path": "",
365
+ }
366
+ }
388
367
  }
389
368
  )
390
369
 
@@ -398,17 +377,3 @@ class NodeCLITest(unittest.TestCase):
398
377
  client.side_effect = Exception("Boom!")
399
378
  with self.assertRaises(Exception):
400
379
  create_client_and_authenticate(ctx)
401
-
402
- # TODO this function has been moved to the common package. A test should
403
- # be added there instead of here
404
- # @patch("vantage6.cli.node.error")
405
- # def test_check_docker(self, error):
406
- # docker = MagicMock()
407
- # try:
408
- # check_docker_running()
409
- # except Exception:
410
- # self.fail("Exception raised!")
411
-
412
- # docker.ping.side_effect = Exception("Boom!")
413
- # with self.assertRaises(SystemExit):
414
- # check_docker_running()