stoobly-agent 1.10.1__py3-none-any.whl → 1.10.2__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.
- stoobly_agent/__init__.py +1 -1
- stoobly_agent/__main__.py +10 -0
- stoobly_agent/app/cli/ca_cert_cli.py +9 -5
- stoobly_agent/app/cli/helpers/replay_facade.py +2 -2
- stoobly_agent/app/cli/intercept_cli.py +5 -5
- stoobly_agent/app/cli/request_cli.py +2 -2
- stoobly_agent/app/cli/scaffold/app.py +14 -5
- stoobly_agent/app/cli/scaffold/app_command.py +0 -4
- stoobly_agent/app/cli/scaffold/app_config.py +49 -2
- stoobly_agent/app/cli/scaffold/app_create_command.py +145 -76
- stoobly_agent/app/cli/scaffold/constants.py +8 -1
- stoobly_agent/app/cli/scaffold/docker/constants.py +3 -1
- stoobly_agent/app/cli/scaffold/docker/service/build_decorator.py +2 -2
- stoobly_agent/app/cli/scaffold/docker/service/builder.py +15 -49
- stoobly_agent/app/cli/scaffold/docker/service/configure_gateway.py +3 -0
- stoobly_agent/app/cli/scaffold/docker/template_files.py +112 -0
- stoobly_agent/app/cli/scaffold/docker/workflow/build_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/builder.py +31 -39
- stoobly_agent/app/cli/scaffold/docker/workflow/command_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/detached_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/dns_decorator.py +2 -3
- stoobly_agent/app/cli/scaffold/docker/workflow/local_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/mock_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/reverse_proxy_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/run_command.py +423 -0
- stoobly_agent/app/cli/scaffold/local/__init__.py +0 -0
- stoobly_agent/app/cli/scaffold/local/service/__init__.py +0 -0
- stoobly_agent/app/cli/scaffold/local/service/builder.py +72 -0
- stoobly_agent/app/cli/scaffold/local/workflow/__init__.py +0 -0
- stoobly_agent/app/cli/scaffold/local/workflow/builder.py +35 -0
- stoobly_agent/app/cli/scaffold/local/workflow/run_command.py +339 -0
- stoobly_agent/app/cli/scaffold/service_command.py +9 -1
- stoobly_agent/app/cli/scaffold/service_config.py +8 -0
- stoobly_agent/app/cli/scaffold/service_create_command.py +18 -6
- stoobly_agent/app/cli/scaffold/service_docker_compose.py +1 -1
- stoobly_agent/app/cli/scaffold/templates/app/.Makefile +2 -2
- stoobly_agent/app/cli/scaffold/templates/app/build/.docker-compose.base.yml +2 -2
- stoobly_agent/app/cli/scaffold/templates/app/entrypoint/.docker-compose.base.yml +2 -2
- stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/build/mock/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/mock/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/mock/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/build/record/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/record/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/record/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/build/test/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/test/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/test/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/mock/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/mock/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/mock/.run +19 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/record/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/record/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/record/.run +19 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/test/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/test/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/test/.run +19 -0
- stoobly_agent/app/cli/scaffold/templates/build/workflows/exec/scaffold/.up +0 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/mock/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/mock/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/mock/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/workflows/record/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/record/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/record/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/workflows/test/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/test/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/test/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/constants.py +35 -19
- stoobly_agent/app/cli/scaffold/templates/factory.py +34 -18
- stoobly_agent/app/cli/scaffold/templates/plugins/cypress/test/.run +21 -0
- stoobly_agent/app/cli/scaffold/templates/plugins/playwright/test/.run +21 -0
- stoobly_agent/app/cli/scaffold/templates/workflow/mock/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/workflow/record/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/workflow/test/run +3 -0
- stoobly_agent/app/cli/scaffold/workflow_command.py +18 -4
- stoobly_agent/app/cli/scaffold/workflow_copy_command.py +5 -4
- stoobly_agent/app/cli/scaffold/workflow_create_command.py +31 -29
- stoobly_agent/app/cli/scaffold/workflow_run_command.py +18 -151
- stoobly_agent/app/cli/scaffold_cli.py +115 -161
- stoobly_agent/app/cli/scenario_cli.py +2 -2
- stoobly_agent/app/cli/types/test.py +2 -2
- stoobly_agent/app/cli/types/workflow_run_command.py +52 -3
- stoobly_agent/app/proxy/handle_mock_service.py +1 -1
- stoobly_agent/app/proxy/intercept_settings.py +5 -25
- stoobly_agent/app/proxy/mock/eval_fixtures_service.py +177 -27
- stoobly_agent/app/proxy/mock/types/__init__.py +22 -1
- stoobly_agent/app/proxy/replay/body_parser_service.py +8 -5
- stoobly_agent/app/proxy/replay/multipart.py +15 -13
- stoobly_agent/app/proxy/replay/replay_request_service.py +2 -2
- stoobly_agent/app/proxy/run.py +3 -0
- stoobly_agent/app/proxy/test/context.py +0 -4
- stoobly_agent/app/proxy/test/context_abc.py +0 -5
- stoobly_agent/cli.py +61 -16
- stoobly_agent/config/data_dir.py +0 -8
- stoobly_agent/public/12-es2015.618ecfd5f735b801b50f.js +1 -0
- stoobly_agent/public/12-es5.618ecfd5f735b801b50f.js +1 -0
- stoobly_agent/public/index.html +1 -1
- stoobly_agent/public/runtime-es2015.77bcd31efed9e5d5d431.js +1 -0
- stoobly_agent/public/runtime-es5.77bcd31efed9e5d5d431.js +1 -0
- stoobly_agent/test/app/cli/intercept/intercept_configure_test.py +17 -6
- stoobly_agent/test/app/cli/scaffold/docker/cli_invoker.py +177 -0
- stoobly_agent/test/app/cli/scaffold/{cli_test.py → docker/cli_test.py} +1 -8
- stoobly_agent/test/app/cli/scaffold/{e2e_test.py → docker/e2e_test.py} +31 -16
- stoobly_agent/test/app/cli/scaffold/local/__init__.py +0 -0
- stoobly_agent/test/app/cli/scaffold/{cli_invoker.py → local/cli_invoker.py} +38 -32
- stoobly_agent/test/app/cli/scaffold/local/e2e_test.py +342 -0
- stoobly_agent/test/app/models/schemas/.stoobly/db/VERSION +1 -1
- stoobly_agent/test/app/proxy/mock/eval_fixtures_service_test.py +903 -2
- stoobly_agent/test/app/proxy/replay/body_parser_service_test.py +95 -3
- stoobly_agent/test/config/data_dir_test.py +2 -7
- stoobly_agent/test/test_helper.py +16 -5
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info}/METADATA +4 -2
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info}/RECORD +150 -122
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info}/WHEEL +1 -1
- stoobly_agent/app/cli/helpers/shell.py +0 -26
- stoobly_agent/public/12-es2015.be58ed0ef449008b932e.js +0 -1
- stoobly_agent/public/12-es5.be58ed0ef449008b932e.js +0 -1
- stoobly_agent/public/runtime-es2015.f8c814b38b27708e91c1.js +0 -1
- stoobly_agent/public/runtime-es5.f8c814b38b27708e91c1.js +0 -1
- /stoobly_agent/app/cli/scaffold/templates/app/build/mock/{.docker-compose.mock.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/mock/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/mock/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/record/{.docker-compose.record.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/record/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/record/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/test/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/test/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/{.docker-compose.mock.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/{.docker-compose.record.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/gateway/mock/{.docker-compose.mock.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/gateway/record/{.docker-compose.record.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/gateway/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/{.docker-compose.exec.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/mock/{.docker-compose.mock.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/record/{.docker-compose.record.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/plugins/cypress/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/plugins/playwright/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/mock/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/mock/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/record/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/record/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/test/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/test/{bin/init → init} +0 -0
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info}/entry_points.txt +0 -0
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,177 @@
|
|
1
|
+
import os
|
2
|
+
import pathlib
|
3
|
+
import pdb
|
4
|
+
import subprocess
|
5
|
+
|
6
|
+
from click.testing import CliRunner
|
7
|
+
|
8
|
+
from stoobly_agent.app.cli import scaffold
|
9
|
+
from stoobly_agent.config.data_dir import DATA_DIR_NAME
|
10
|
+
|
11
|
+
|
12
|
+
class ScaffoldCliInvoker():
|
13
|
+
|
14
|
+
@staticmethod
|
15
|
+
def cli_app_create(runner: CliRunner, app_dir_path: str, app_name: str):
|
16
|
+
pathlib.Path(f"{app_dir_path}/{DATA_DIR_NAME}").mkdir(parents=True, exist_ok=True)
|
17
|
+
|
18
|
+
result = runner.invoke(scaffold, ['app', 'create',
|
19
|
+
'--app-dir-path', app_dir_path,
|
20
|
+
'--quiet',
|
21
|
+
app_name
|
22
|
+
])
|
23
|
+
|
24
|
+
if result.exit_code != 0:
|
25
|
+
print(f"Command failed with exit code {result.exit_code}")
|
26
|
+
print(f"Output: {result.output}")
|
27
|
+
print(f"Exception: {result.exception}")
|
28
|
+
|
29
|
+
assert result.exit_code == 0
|
30
|
+
output = result.stdout
|
31
|
+
assert not output
|
32
|
+
|
33
|
+
@staticmethod
|
34
|
+
def cli_app_mkcert(runner: CliRunner, app_dir_path: str):
|
35
|
+
result = runner.invoke(scaffold, ['app', 'mkcert',
|
36
|
+
'--app-dir-path', app_dir_path,
|
37
|
+
'--context-dir-path', app_dir_path,
|
38
|
+
])
|
39
|
+
|
40
|
+
assert result.exit_code == 0
|
41
|
+
output = result.stdout
|
42
|
+
assert not output
|
43
|
+
|
44
|
+
@staticmethod
|
45
|
+
def cli_service_create(runner: CliRunner, app_dir_path: str, hostname: str, service_name: str, https: bool):
|
46
|
+
scheme = 'http'
|
47
|
+
port = '80'
|
48
|
+
if https == True:
|
49
|
+
scheme = 'https'
|
50
|
+
port = '443'
|
51
|
+
|
52
|
+
result = runner.invoke(scaffold, ['service', 'create',
|
53
|
+
'--app-dir-path', app_dir_path,
|
54
|
+
'--env', 'TEST',
|
55
|
+
'--hostname', hostname,
|
56
|
+
'--scheme', scheme,
|
57
|
+
'--port', port,
|
58
|
+
'--quiet',
|
59
|
+
'--workflow', 'mock',
|
60
|
+
'--workflow', 'record',
|
61
|
+
'--workflow', 'test',
|
62
|
+
service_name
|
63
|
+
])
|
64
|
+
assert result.exit_code == 0
|
65
|
+
output = result.stdout
|
66
|
+
assert not output
|
67
|
+
|
68
|
+
# Specific flags for assets
|
69
|
+
@staticmethod
|
70
|
+
def cli_service_create_assets(runner: CliRunner, app_dir_path: str, hostname: str, service_name: str, https: bool):
|
71
|
+
scheme = 'http'
|
72
|
+
port = '80'
|
73
|
+
if https == True:
|
74
|
+
scheme = 'https'
|
75
|
+
port = '443'
|
76
|
+
|
77
|
+
result = runner.invoke(scaffold, ['service', 'create',
|
78
|
+
'--app-dir-path', app_dir_path,
|
79
|
+
'--hostname', hostname,
|
80
|
+
'--scheme', scheme,
|
81
|
+
'--port', port,
|
82
|
+
'--upstream-hostname', hostname,
|
83
|
+
'--upstream-port', 80,
|
84
|
+
'--upstream-scheme', 'http',
|
85
|
+
'--detached',
|
86
|
+
'--quiet',
|
87
|
+
'--workflow', 'test',
|
88
|
+
service_name
|
89
|
+
])
|
90
|
+
assert result.exit_code == 0
|
91
|
+
output = result.stdout
|
92
|
+
assert not output
|
93
|
+
|
94
|
+
@staticmethod
|
95
|
+
def cli_service_delete(runner: CliRunner, app_dir_path: str, service_name: str):
|
96
|
+
result = runner.invoke(scaffold, ['service', 'delete',
|
97
|
+
'--app-dir-path', app_dir_path,
|
98
|
+
service_name
|
99
|
+
])
|
100
|
+
assert result.exit_code == 0
|
101
|
+
output = result.stdout
|
102
|
+
assert 'error' not in output.lower()
|
103
|
+
|
104
|
+
@staticmethod
|
105
|
+
def cli_workflow_create(runner: CliRunner, app_dir_path: str, service_name: str):
|
106
|
+
result = runner.invoke(scaffold, ['workflow', 'create',
|
107
|
+
'--app-dir-path', app_dir_path,
|
108
|
+
'--service', service_name,
|
109
|
+
'--template', 'mock',
|
110
|
+
'ci',
|
111
|
+
])
|
112
|
+
|
113
|
+
assert result.exit_code == 0
|
114
|
+
|
115
|
+
@staticmethod
|
116
|
+
def cli_workflow_up(runner: CliRunner, app_dir_path: str, target_workflow_name: str):
|
117
|
+
command = ['workflow', 'up',
|
118
|
+
'--app-dir-path', app_dir_path,
|
119
|
+
'--context-dir-path', app_dir_path,
|
120
|
+
'--yes',
|
121
|
+
target_workflow_name,
|
122
|
+
]
|
123
|
+
result = runner.invoke(scaffold, command)
|
124
|
+
|
125
|
+
if result.exit_code != 0:
|
126
|
+
print(f"Command failed with exit code {result.exit_code}")
|
127
|
+
print(f"Output: {result.output}")
|
128
|
+
print(f"Exception: {result.exception}")
|
129
|
+
|
130
|
+
assert result.exit_code == 0
|
131
|
+
|
132
|
+
@staticmethod
|
133
|
+
def cli_workflow_down(runner: CliRunner, app_dir_path: str, target_workflow_name: str):
|
134
|
+
command = ['workflow', 'down',
|
135
|
+
'--app-dir-path', app_dir_path,
|
136
|
+
'--context-dir-path', app_dir_path,
|
137
|
+
target_workflow_name,
|
138
|
+
]
|
139
|
+
result = runner.invoke(scaffold, command)
|
140
|
+
|
141
|
+
if result.exit_code != 0:
|
142
|
+
print(f"Down command failed with exit code {result.exit_code}")
|
143
|
+
print(f"Output: {result.output}")
|
144
|
+
print(f"Exception: {result.exception}")
|
145
|
+
|
146
|
+
assert result.exit_code == 0
|
147
|
+
|
148
|
+
@staticmethod
|
149
|
+
def makefile_workflow_up(runner: CliRunner, app_dir_path: str, target_workflow_name: str):
|
150
|
+
command = ['make', '-f', os.path.join(app_dir_path, '.stoobly', 'services', 'Makefile'),
|
151
|
+
target_workflow_name,
|
152
|
+
]
|
153
|
+
|
154
|
+
# Run the command using subprocess
|
155
|
+
# Instead of piping, print to stdout and stderr
|
156
|
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
157
|
+
|
158
|
+
if result.returncode != 0:
|
159
|
+
print(f"Command failed with exit code {result.returncode}")
|
160
|
+
print(f"Output: {result.stdout}")
|
161
|
+
print(f"Exception: {result.stderr}")
|
162
|
+
|
163
|
+
assert result.returncode == 0
|
164
|
+
|
165
|
+
@staticmethod
|
166
|
+
def makefile_workflow_down(runner: CliRunner, app_dir_path: str, target_workflow_name: str):
|
167
|
+
command = ['make', '-f', os.path.join(app_dir_path, '.stoobly', 'services', 'Makefile'),
|
168
|
+
f"{target_workflow_name}/down"
|
169
|
+
]
|
170
|
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
171
|
+
|
172
|
+
if result.returncode != 0:
|
173
|
+
print(f"Command failed with exit code {result.returncode}")
|
174
|
+
print(f"Output: {result.stdout}")
|
175
|
+
print(f"Exception: {result.stderr}")
|
176
|
+
|
177
|
+
assert result.returncode == 0
|
@@ -12,7 +12,7 @@ from stoobly_agent.app.cli.scaffold.constants import (
|
|
12
12
|
)
|
13
13
|
from stoobly_agent.app.cli.scaffold.service_docker_compose import ServiceDockerCompose
|
14
14
|
from stoobly_agent.config.data_dir import DataDir
|
15
|
-
from stoobly_agent.test.app.cli.scaffold.e2e_test import ScaffoldCliInvoker
|
15
|
+
from stoobly_agent.test.app.cli.scaffold.docker.e2e_test import ScaffoldCliInvoker
|
16
16
|
from stoobly_agent.test.test_helper import reset
|
17
17
|
|
18
18
|
|
@@ -81,13 +81,6 @@ class TestScaffoldCli():
|
|
81
81
|
|
82
82
|
# Generate certs
|
83
83
|
ScaffoldCliInvoker.cli_app_mkcert(runner, app_dir_path)
|
84
|
-
|
85
|
-
@pytest.fixture(scope="class", autouse=True)
|
86
|
-
def cleanup_after_all(self, runner, app_dir_path, target_workflow_name):
|
87
|
-
yield
|
88
|
-
ScaffoldCliInvoker.cli_workflow_down(runner, app_dir_path, target_workflow_name)
|
89
|
-
shutil.rmtree(app_dir_path)
|
90
|
-
|
91
84
|
|
92
85
|
def test_service_delete(self, runner, app_dir_path, external_service_docker_compose):
|
93
86
|
app = App(app_dir_path, SERVICES_NAMESPACE)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
from pathlib import Path
|
2
1
|
import pdb
|
2
|
+
import pytest
|
3
3
|
import shutil
|
4
4
|
|
5
5
|
from click.testing import CliRunner
|
6
|
-
import
|
6
|
+
from pathlib import Path
|
7
7
|
|
8
8
|
from stoobly_agent.app.cli.scaffold.app import App
|
9
9
|
from stoobly_agent.app.cli.scaffold.constants import (
|
@@ -22,10 +22,9 @@ from stoobly_agent.app.cli.scaffold.workflow_validate_command import (
|
|
22
22
|
WorkflowValidateCommand,
|
23
23
|
)
|
24
24
|
from stoobly_agent.config.data_dir import DataDir
|
25
|
-
from stoobly_agent.test.app.cli.scaffold.cli_invoker import ScaffoldCliInvoker
|
25
|
+
from stoobly_agent.test.app.cli.scaffold.docker.cli_invoker import ScaffoldCliInvoker
|
26
26
|
from stoobly_agent.test.test_helper import reset
|
27
27
|
|
28
|
-
|
29
28
|
@pytest.mark.e2e
|
30
29
|
class TestScaffoldE2e():
|
31
30
|
|
@@ -49,12 +48,12 @@ class TestScaffoldE2e():
|
|
49
48
|
yield tmp_path
|
50
49
|
|
51
50
|
@pytest.fixture(scope='class', autouse=True)
|
52
|
-
def app_dir_path(self, temp_dir
|
51
|
+
def app_dir_path(self, temp_dir):
|
53
52
|
yield temp_dir
|
54
53
|
|
55
54
|
@pytest.fixture(scope='class')
|
56
55
|
def mock_data_directory_path(self):
|
57
|
-
yield Path(__file__).parent.parent.parent.parent / 'mock_data'
|
56
|
+
yield Path(__file__).parent.parent.parent.parent.parent / 'mock_data'
|
58
57
|
|
59
58
|
@pytest.fixture(scope='class')
|
60
59
|
def local_service_mock_docker_compose_path(self, mock_data_directory_path):
|
@@ -85,7 +84,6 @@ class TestScaffoldE2e():
|
|
85
84
|
def local_service_name(self):
|
86
85
|
yield "my-httpbin"
|
87
86
|
|
88
|
-
|
89
87
|
class TestRecordWorkflow():
|
90
88
|
@pytest.fixture(scope='class', autouse=True)
|
91
89
|
def target_workflow_name(self):
|
@@ -135,7 +133,6 @@ class TestScaffoldE2e():
|
|
135
133
|
def cleanup_after_all(self, runner, app_dir_path, target_workflow_name):
|
136
134
|
yield
|
137
135
|
ScaffoldCliInvoker.cli_workflow_down(runner, app_dir_path, target_workflow_name)
|
138
|
-
shutil.rmtree(app_dir_path)
|
139
136
|
|
140
137
|
def test_core_services(self, app_dir_path, target_workflow_name):
|
141
138
|
app = App(app_dir_path, SERVICES_NAMESPACE)
|
@@ -197,15 +194,21 @@ class TestScaffoldE2e():
|
|
197
194
|
|
198
195
|
@pytest.fixture(scope='class')
|
199
196
|
def external_service_docker_compose(self, app_dir_path, target_workflow_name, external_service_name, hostname):
|
200
|
-
yield ServiceDockerCompose(
|
197
|
+
yield ServiceDockerCompose(
|
198
|
+
app_dir_path=app_dir_path, target_workflow_name=target_workflow_name, service_name=external_service_name, hostname=hostname
|
199
|
+
)
|
201
200
|
|
202
201
|
@pytest.fixture(scope='class')
|
203
202
|
def local_service_docker_compose(self, app_dir_path, target_workflow_name, local_service_name, local_hostname):
|
204
|
-
yield ServiceDockerCompose(
|
203
|
+
yield ServiceDockerCompose(
|
204
|
+
app_dir_path=app_dir_path, target_workflow_name=target_workflow_name, service_name=local_service_name, hostname=local_hostname
|
205
|
+
)
|
205
206
|
|
206
207
|
@pytest.fixture(scope='class')
|
207
208
|
def assets_service_docker_compose(self, app_dir_path, target_workflow_name, assets_service_name, assets_hostname):
|
208
|
-
yield ServiceDockerCompose(
|
209
|
+
yield ServiceDockerCompose(
|
210
|
+
app_dir_path=app_dir_path, target_workflow_name=target_workflow_name, service_name=assets_service_name, hostname=assets_hostname
|
211
|
+
)
|
209
212
|
|
210
213
|
@pytest.fixture(scope='class', autouse=True)
|
211
214
|
def setup_docker_composes(self, managed_services_docker_compose, external_service_docker_compose, local_service_docker_compose, assets_service_docker_compose):
|
@@ -215,7 +218,7 @@ class TestScaffoldE2e():
|
|
215
218
|
self.assets_service_docker_compose = assets_service_docker_compose
|
216
219
|
|
217
220
|
@pytest.fixture(scope="class", autouse=True)
|
218
|
-
def create_scaffold_setup(self, runner, app_name, app_dir_path, target_workflow_name, external_service_docker_compose, local_service_docker_compose, assets_service_docker_compose, mock_data_directory_path, assets_service_mock_docker_compose_path):
|
221
|
+
def create_scaffold_setup(self, runner, app_name, app_dir_path, target_workflow_name, external_service_docker_compose, local_service_docker_compose, assets_service_docker_compose, mock_data_directory_path, assets_service_mock_docker_compose_path, workflow_up_method: str):
|
219
222
|
|
220
223
|
ScaffoldCliInvoker.cli_app_create(runner, app_dir_path, app_name)
|
221
224
|
|
@@ -252,13 +255,25 @@ class TestScaffoldE2e():
|
|
252
255
|
with open(f"{command.public_dir_path}/shared_file.txt", 'w') as file:
|
253
256
|
file.write('this is a shared file')
|
254
257
|
|
255
|
-
|
258
|
+
# Use parameterized workflow up method
|
259
|
+
if workflow_up_method == 'cli':
|
260
|
+
ScaffoldCliInvoker.cli_workflow_up(runner, app_dir_path, target_workflow_name)
|
261
|
+
else: # makefile
|
262
|
+
ScaffoldCliInvoker.makefile_workflow_up(runner, app_dir_path, target_workflow_name)
|
256
263
|
|
257
264
|
@pytest.fixture(scope="class", autouse=True)
|
258
|
-
def cleanup_after_all(self, runner, app_dir_path, target_workflow_name):
|
265
|
+
def cleanup_after_all(self, runner, app_dir_path, target_workflow_name, workflow_up_method):
|
259
266
|
yield
|
260
|
-
|
261
|
-
|
267
|
+
# Use the same method for down as was used for up
|
268
|
+
if workflow_up_method == 'cli':
|
269
|
+
ScaffoldCliInvoker.cli_workflow_down(runner, app_dir_path, target_workflow_name)
|
270
|
+
else: # makefile
|
271
|
+
ScaffoldCliInvoker.makefile_workflow_down(runner, app_dir_path, target_workflow_name)
|
272
|
+
|
273
|
+
@pytest.fixture(scope='class', params=['cli', 'makefile'])
|
274
|
+
def workflow_up_method(self, request):
|
275
|
+
"""Parameterized fixture that alternates between CLI and Makefile workflow up methods."""
|
276
|
+
return request.param
|
262
277
|
|
263
278
|
def test_no_core_services(self, app_dir_path, target_workflow_name):
|
264
279
|
app = App(app_dir_path, SERVICES_NAMESPACE)
|
File without changes
|
@@ -7,7 +7,7 @@ from stoobly_agent.app.cli import scaffold
|
|
7
7
|
from stoobly_agent.config.data_dir import DATA_DIR_NAME
|
8
8
|
|
9
9
|
|
10
|
-
class
|
10
|
+
class LocalScaffoldCliInvoker():
|
11
11
|
|
12
12
|
@staticmethod
|
13
13
|
def cli_app_create(runner: CliRunner, app_dir_path: str, app_name: str):
|
@@ -15,6 +15,8 @@ class ScaffoldCliInvoker():
|
|
15
15
|
|
16
16
|
result = runner.invoke(scaffold, ['app', 'create',
|
17
17
|
'--app-dir-path', app_dir_path,
|
18
|
+
'--proxy-port', '8081',
|
19
|
+
'--run-on', 'local',
|
18
20
|
'--quiet',
|
19
21
|
app_name
|
20
22
|
])
|
@@ -23,17 +25,6 @@ class ScaffoldCliInvoker():
|
|
23
25
|
output = result.stdout
|
24
26
|
assert not output
|
25
27
|
|
26
|
-
@staticmethod
|
27
|
-
def cli_app_mkcert(runner: CliRunner, app_dir_path: str):
|
28
|
-
result = runner.invoke(scaffold, ['app', 'mkcert',
|
29
|
-
'--app-dir-path', app_dir_path,
|
30
|
-
'--context-dir-path', app_dir_path,
|
31
|
-
])
|
32
|
-
|
33
|
-
assert result.exit_code == 0
|
34
|
-
output = result.stdout
|
35
|
-
assert not output
|
36
|
-
|
37
28
|
@staticmethod
|
38
29
|
def cli_service_create(runner: CliRunner, app_dir_path: str, hostname: str, service_name: str, https: bool):
|
39
30
|
scheme = 'http'
|
@@ -58,25 +49,17 @@ class ScaffoldCliInvoker():
|
|
58
49
|
output = result.stdout
|
59
50
|
assert not output
|
60
51
|
|
61
|
-
# Specific flags for assets
|
62
52
|
@staticmethod
|
63
|
-
def
|
64
|
-
|
65
|
-
port = '80'
|
66
|
-
if https == True:
|
67
|
-
scheme = 'https'
|
68
|
-
port = '443'
|
69
|
-
|
53
|
+
def cli_service_create_local(runner: CliRunner, app_dir_path: str, hostname: str, service_name: str):
|
54
|
+
"""Create a local service (not external)"""
|
70
55
|
result = runner.invoke(scaffold, ['service', 'create',
|
71
56
|
'--app-dir-path', app_dir_path,
|
72
57
|
'--hostname', hostname,
|
73
|
-
'--scheme',
|
74
|
-
'--port',
|
75
|
-
'--upstream-hostname', hostname,
|
76
|
-
'--upstream-port', 80,
|
77
|
-
'--upstream-scheme', 'http',
|
78
|
-
'--detached',
|
58
|
+
'--scheme', 'http',
|
59
|
+
'--port', '3000',
|
79
60
|
'--quiet',
|
61
|
+
'--workflow', 'mock',
|
62
|
+
'--workflow', 'record',
|
80
63
|
'--workflow', 'test',
|
81
64
|
service_name
|
82
65
|
])
|
@@ -104,21 +87,40 @@ class ScaffoldCliInvoker():
|
|
104
87
|
])
|
105
88
|
|
106
89
|
assert result.exit_code == 0
|
107
|
-
output = result.stdout
|
108
|
-
assert not output
|
109
90
|
|
110
91
|
@staticmethod
|
111
92
|
def cli_workflow_up(runner: CliRunner, app_dir_path: str, target_workflow_name: str):
|
112
93
|
command = ['workflow', 'up',
|
113
94
|
'--app-dir-path', app_dir_path,
|
114
95
|
'--context-dir-path', app_dir_path,
|
96
|
+
'--yes',
|
115
97
|
target_workflow_name,
|
116
98
|
]
|
117
99
|
result = runner.invoke(scaffold, command)
|
118
100
|
|
101
|
+
if result.exit_code != 0:
|
102
|
+
print(f"Command failed with exit code {result.exit_code}")
|
103
|
+
print(f"Output: {result.output}")
|
104
|
+
print(f"Exception: {result.exception}")
|
105
|
+
|
119
106
|
assert result.exit_code == 0
|
120
|
-
|
121
|
-
|
107
|
+
return result
|
108
|
+
|
109
|
+
@staticmethod
|
110
|
+
def cli_workflow_logs(runner: CliRunner, app_dir_path: str, target_workflow_name: str):
|
111
|
+
command = ['workflow', 'logs',
|
112
|
+
'--app-dir-path', app_dir_path,
|
113
|
+
target_workflow_name,
|
114
|
+
]
|
115
|
+
result = runner.invoke(scaffold, command)
|
116
|
+
|
117
|
+
if result.exit_code != 0:
|
118
|
+
print(f"Logs command failed with exit code {result.exit_code}")
|
119
|
+
print(f"Output: {result.output}")
|
120
|
+
print(f"Exception: {result.exception}")
|
121
|
+
|
122
|
+
assert result.exit_code == 0
|
123
|
+
return result
|
122
124
|
|
123
125
|
@staticmethod
|
124
126
|
def cli_workflow_down(runner: CliRunner, app_dir_path: str, target_workflow_name: str):
|
@@ -129,6 +131,10 @@ class ScaffoldCliInvoker():
|
|
129
131
|
]
|
130
132
|
result = runner.invoke(scaffold, command)
|
131
133
|
|
134
|
+
if result.exit_code != 0:
|
135
|
+
print(f"Down command failed with exit code {result.exit_code}")
|
136
|
+
print(f"Output: {result.output}")
|
137
|
+
print(f"Exception: {result.exception}")
|
138
|
+
|
132
139
|
assert result.exit_code == 0
|
133
|
-
|
134
|
-
assert output
|
140
|
+
return result
|