Summary
The ConnectionBroker logs the path of the Unicon CLI log file at INFO level:
Unicon CLI log will be written to: .../pyats_results/sd-dc-c8kv-01-cli-4700779846.log
But this file is not present after the test run completes — it is silently deleted before the user has a chance to inspect it. The file is only retained when running with NAC_TEST_DEBUG=true.
Root Cause
The Unicon CLI log files are written to {output_dir}/pyats_results/ during the test run (via connection_broker.py). At the start of report generation, MultiArchiveReportGenerator.generate_reports_from_archives() unconditionally wipes the entire pyats_results/ directory:
nac_test/pyats_core/reporting/multi_archive_generator.py, lines 98–101:
# Clean and prepare results directory
if self.pyats_results_dir.exists():
shutil.rmtree(self.pyats_results_dir)
self.pyats_results_dir.mkdir(parents=True)
This happens before any archive is extracted and has no DEBUG_MODE or NAC_TEST_PYATS_KEEP_REPORT_DATA guard — unlike the other cleanup steps in the same file (JSONL files) and in orchestrator.py (archive files after extraction).
Impact
- The INFO-level log message referencing the CLI log path creates a false expectation: users are told where the log will be, but the file is gone by the time they look.
- Connection failures, authentication issues, and Unicon state machine errors can only be diagnosed by re-running with
NAC_TEST_DEBUG=true.
- This is particularly painful for intermittent or environment-specific failures.
Expected Behavior
The Unicon CLI log files should be retained in the output directory after the test run, at any log level. The shutil.rmtree cleanup should either:
- Move the CLI log files out before wiping, then move them back, or
- Respect
DEBUG_MODE / NAC_TEST_PYATS_KEEP_REPORT_DATA the same way the other cleanup steps do.
Steps to Reproduce
- Run a D2D test against any device (reachable or not)
- Observe the INFO log:
Unicon CLI log will be written to: .../pyats_results/<hostname>-cli-<timestamp>.log
- After the run completes, check the output directory — the
*-cli-*.log file is absent
- Re-run with
NAC_TEST_DEBUG=true — the file is now present
References
- Unicon CLI log file creation:
connection_broker.py ~lines 325–340
- Unconditional
shutil.rmtree: multi_archive_generator.py lines 98–101
- DEBUG-guarded JSONL cleanup (same file): lines 155–164
- DEBUG-guarded archive cleanup:
orchestrator.py lines 836–850
Summary
The ConnectionBroker logs the path of the Unicon CLI log file at INFO level:
But this file is not present after the test run completes — it is silently deleted before the user has a chance to inspect it. The file is only retained when running with
NAC_TEST_DEBUG=true.Root Cause
The Unicon CLI log files are written to
{output_dir}/pyats_results/during the test run (viaconnection_broker.py). At the start of report generation,MultiArchiveReportGenerator.generate_reports_from_archives()unconditionally wipes the entirepyats_results/directory:nac_test/pyats_core/reporting/multi_archive_generator.py, lines 98–101:This happens before any archive is extracted and has no
DEBUG_MODEorNAC_TEST_PYATS_KEEP_REPORT_DATAguard — unlike the other cleanup steps in the same file (JSONL files) and inorchestrator.py(archive files after extraction).Impact
NAC_TEST_DEBUG=true.Expected Behavior
The Unicon CLI log files should be retained in the output directory after the test run, at any log level. The
shutil.rmtreecleanup should either:DEBUG_MODE/NAC_TEST_PYATS_KEEP_REPORT_DATAthe same way the other cleanup steps do.Steps to Reproduce
Unicon CLI log will be written to: .../pyats_results/<hostname>-cli-<timestamp>.log*-cli-*.logfile is absentNAC_TEST_DEBUG=true— the file is now presentReferences
connection_broker.py~lines 325–340shutil.rmtree:multi_archive_generator.pylines 98–101orchestrator.pylines 836–850