utils_devops 0.1.158__tar.gz → 0.1.159__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.
- {utils_devops-0.1.158 → utils_devops-0.1.159}/PKG-INFO +1 -1
- {utils_devops-0.1.158 → utils_devops-0.1.159}/pyproject.toml +1 -1
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/docker_ops.py +15 -16
- {utils_devops-0.1.158 → utils_devops-0.1.159}/README.md +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/__init__.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/core/__init__.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/core/datetimes.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/core/envs.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/core/files.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/core/logs.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/core/script_helpers.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/core/strings.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/core/systems.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/__init__.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/aws_ops.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/git_ops.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/interaction_ops.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/metrics_ops.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/network_ops.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/nginx_ops.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/notification_ops.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/performance_ops.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/ssh_ops.py +0 -0
- {utils_devops-0.1.158 → utils_devops-0.1.159}/src/utils_devops/extras/vault_ops.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: utils_devops
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.159
|
|
4
4
|
Summary: Lightweight DevOps utilities for automation scripts: config editing (YAML/JSON/INI/.env), templating, diffing, and CLI tools
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: devops,automation,nginx,cli,jinja2,yaml,config,diff,templating,logging,docker,compose,file-ops
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "utils_devops"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.159" # Bumped for new string features + diffing
|
|
4
4
|
description = "Lightweight DevOps utilities for automation scripts: config editing (YAML/JSON/INI/.env), templating, diffing, and CLI tools"
|
|
5
5
|
authors = ["Hamed Sheikhan <sh.sheikhan.m@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -8,7 +8,6 @@ import json
|
|
|
8
8
|
import os
|
|
9
9
|
import re
|
|
10
10
|
from logging import Logger
|
|
11
|
-
import re
|
|
12
11
|
import sys
|
|
13
12
|
import tarfile
|
|
14
13
|
import tempfile
|
|
@@ -618,7 +617,7 @@ def compose_restart(compose_file: str, remove_volumes: bool = False,
|
|
|
618
617
|
|
|
619
618
|
def compose_ps(compose_file: str, project_name: Optional[str] = None, env_file: Optional[str] = None) -> List[ContainerInfo]:
|
|
620
619
|
"""List compose services status using detected compose command"""
|
|
621
|
-
result = run_compose_command(compose_file, ["ps", "--format", "json"], project_name , env_file)
|
|
620
|
+
result = run_compose_command(compose_file, ["ps" ,"-a", "--format", "json"], project_name , env_file)
|
|
622
621
|
|
|
623
622
|
containers = []
|
|
624
623
|
try:
|
|
@@ -909,7 +908,7 @@ def check_health_from_compose_ps(compose_file: str) -> Dict[str, Any]:
|
|
|
909
908
|
"""
|
|
910
909
|
try:
|
|
911
910
|
# Run docker compose ps with JSON format
|
|
912
|
-
result = run_compose_command(compose_file, ["ps", "--format", "json"])
|
|
911
|
+
result = run_compose_command(compose_file, ["ps","-a", "--format", "json"])
|
|
913
912
|
if result.rc != 0:
|
|
914
913
|
return {"healthy": False, "error": f"docker compose ps failed: {result.stderr}"}
|
|
915
914
|
|
|
@@ -2220,8 +2219,7 @@ def playwright_test_compose(
|
|
|
2220
2219
|
pull_missing: bool = True,
|
|
2221
2220
|
no_build: bool = True,
|
|
2222
2221
|
no_pull: bool = True,
|
|
2223
|
-
|
|
2224
|
-
# Keep services up after each test_compose call so we can sequence them
|
|
2222
|
+
keep_compose_up: bool = False,
|
|
2225
2223
|
dry_run: bool = False,
|
|
2226
2224
|
project_name: Optional[str] = None,
|
|
2227
2225
|
logger: Optional[logger] = None,
|
|
@@ -2231,7 +2229,6 @@ def playwright_test_compose(
|
|
|
2231
2229
|
application compose and a separate Playwright compose. This function reuses the
|
|
2232
2230
|
existing `test_compose` function to perform validation, startup and health checks for
|
|
2233
2231
|
the application compose.
|
|
2234
|
-
|
|
2235
2232
|
Behavior summary:
|
|
2236
2233
|
1. Validate inputs and (optionally) update version as in test_compose.
|
|
2237
2234
|
2. Set STATIC_CAPTCHA=true in the system process environment (without modifying the file).
|
|
@@ -2241,13 +2238,11 @@ def playwright_test_compose(
|
|
|
2241
2238
|
5. Follow logs (simulating -f) for the Playwright service(s) while polling the compose state
|
|
2242
2239
|
to detect completion, and determine pass/fail from exit status and log patterns.
|
|
2243
2240
|
6. Return a detailed result dict similar in structure to test_compose.
|
|
2244
|
-
|
|
2245
2241
|
Notes:
|
|
2246
2242
|
- Reuses `test_compose` for application startup and health checks.
|
|
2247
2243
|
- Sets STATIC_CAPTCHA in the process environment only (os.environ).
|
|
2248
2244
|
- Does not automatically bring services down; that is left to the caller.
|
|
2249
2245
|
- Success is determined by all containers exiting with code 0 and/or presence of success patterns in logs.
|
|
2250
|
-
|
|
2251
2246
|
Returns:
|
|
2252
2247
|
Dict with keys: test_id, success, steps, app_result, logs_captured, duration, error
|
|
2253
2248
|
"""
|
|
@@ -2263,6 +2258,8 @@ def playwright_test_compose(
|
|
|
2263
2258
|
"duration": 0.0,
|
|
2264
2259
|
"error": None,
|
|
2265
2260
|
}
|
|
2261
|
+
#project_name_playwright = f"playwright-{test_id[:8]}"
|
|
2262
|
+
project_name_playwright = project_name
|
|
2266
2263
|
try:
|
|
2267
2264
|
logger.info(f"▶️ Playwright test workflow starting ({test_id})")
|
|
2268
2265
|
logger.info(f" Compose files: app={compose_file} playwright={playwright_compose_file}")
|
|
@@ -2316,14 +2313,13 @@ def playwright_test_compose(
|
|
|
2316
2313
|
logger.info(" Application stack is up and healthy")
|
|
2317
2314
|
else:
|
|
2318
2315
|
logger.info("Step 3: application start skipped (dry run)")
|
|
2319
|
-
# Step 4: Start Playwright compose using compose_up
|
|
2316
|
+
# Step 4: Start Playwright compose using compose_up with unique project name
|
|
2320
2317
|
logger.info("Step 4: bringing up Playwright runner stack with compose_up")
|
|
2321
2318
|
if not dry_run:
|
|
2322
2319
|
up_success = compose_up(
|
|
2323
2320
|
playwright_compose_file,
|
|
2324
2321
|
services=playwright_services,
|
|
2325
|
-
project_name=
|
|
2326
|
-
# Assume detached by default or add param if needed; help shows no param for detached, perhaps always detached
|
|
2322
|
+
project_name=project_name_playwright,
|
|
2327
2323
|
)
|
|
2328
2324
|
if not up_success:
|
|
2329
2325
|
raise DockerOpsError("Playwright compose_up failed")
|
|
@@ -2338,11 +2334,12 @@ def playwright_test_compose(
|
|
|
2338
2334
|
deadline = time.time() + health_timeout
|
|
2339
2335
|
finished = False
|
|
2340
2336
|
timed_out = False
|
|
2337
|
+
time.sleep(5) # Give time for container to start producing logs
|
|
2341
2338
|
while not finished and not timed_out:
|
|
2342
2339
|
# Fetch current log snapshot
|
|
2343
2340
|
for svc in pw_services:
|
|
2344
2341
|
try:
|
|
2345
|
-
lines = [l.
|
|
2342
|
+
lines = [l.message for l in compose_logs(playwright_compose_file, services=[svc], tail=log_tail, project_name=project_name_playwright,follow=True)]
|
|
2346
2343
|
except Exception as e:
|
|
2347
2344
|
lines = [f"Error fetching logs: {str(e)}"]
|
|
2348
2345
|
# Append new unique lines
|
|
@@ -2351,7 +2348,7 @@ def playwright_test_compose(
|
|
|
2351
2348
|
logs_acc[svc].append(ln)
|
|
2352
2349
|
logger.info(f"[{svc}] {ln}") # Simulate real-time logging
|
|
2353
2350
|
# Check if all services have exited
|
|
2354
|
-
ps = compose_ps(playwright_compose_file, project_name=
|
|
2351
|
+
ps = compose_ps(playwright_compose_file, project_name=project_name_playwright)
|
|
2355
2352
|
running = any(
|
|
2356
2353
|
'running' in (c.status or '').lower() or 'up' in (c.status or '').lower()
|
|
2357
2354
|
for c in ps if (c.service or '') in pw_services
|
|
@@ -2376,7 +2373,7 @@ def playwright_test_compose(
|
|
|
2376
2373
|
logger.info("Step 6: analyzing Playwright runner outcome")
|
|
2377
2374
|
if not dry_run:
|
|
2378
2375
|
# Get exit codes
|
|
2379
|
-
ps = compose_ps(playwright_compose_file, project_name=
|
|
2376
|
+
ps = compose_ps(playwright_compose_file, project_name=project_name_playwright)
|
|
2380
2377
|
exit_codes = {}
|
|
2381
2378
|
for c in ps:
|
|
2382
2379
|
if (c.service or '') in pw_services:
|
|
@@ -2402,9 +2399,10 @@ def playwright_test_compose(
|
|
|
2402
2399
|
else:
|
|
2403
2400
|
result['success'] = True # Assume success in dry run
|
|
2404
2401
|
result['duration'] = (dt_ops.current_datetime() - start_time).total_seconds()
|
|
2405
|
-
if not
|
|
2402
|
+
if not keep_compose_up :
|
|
2406
2403
|
compose_down(
|
|
2407
2404
|
compose_file=playwright_compose_file,
|
|
2405
|
+
project_name=project_name_playwright
|
|
2408
2406
|
)
|
|
2409
2407
|
logger.info("Playwright compose down")
|
|
2410
2408
|
compose_down(
|
|
@@ -2416,9 +2414,10 @@ def playwright_test_compose(
|
|
|
2416
2414
|
result['duration'] = (dt_ops.current_datetime() - start_time).total_seconds()
|
|
2417
2415
|
result['error'] = str(e)
|
|
2418
2416
|
logger.error(f"Playwright test workflow failed ({test_id}): {e}")
|
|
2419
|
-
if not
|
|
2417
|
+
if not keep_compose_up :
|
|
2420
2418
|
compose_down(
|
|
2421
2419
|
compose_file=playwright_compose_file,
|
|
2420
|
+
project_name=project_name_playwright
|
|
2422
2421
|
)
|
|
2423
2422
|
logger.info("Playwright compose down")
|
|
2424
2423
|
compose_down(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|