159 lines
6.6 KiB
Go
159 lines
6.6 KiB
Go
package cluster
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
|
|
"scm.bstein.dev/bstein/ananke/internal/state"
|
|
)
|
|
|
|
// TestHookReportArchiveDir runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookReportArchiveDir() string.
|
|
// Why: exposes report archive directory resolver internals to top-level tests.
|
|
func (o *Orchestrator) TestHookReportArchiveDir() string {
|
|
return o.reportArchiveDir()
|
|
}
|
|
|
|
// TestHookWriteRunRecordArtifact runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookWriteRunRecordArtifact(record state.RunRecord) error.
|
|
// Why: exposes run-record artifact writer internals to top-level tests.
|
|
func (o *Orchestrator) TestHookWriteRunRecordArtifact(record state.RunRecord) error {
|
|
return o.writeRunRecordArtifact(record)
|
|
}
|
|
|
|
// TestHookStartupReportPath runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookStartupReportPath() string.
|
|
// Why: exposes startup report path helper internals to top-level tests.
|
|
func (o *Orchestrator) TestHookStartupReportPath() string {
|
|
return o.startupReportPath()
|
|
}
|
|
|
|
// TestHookStartupProgressPath runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookStartupProgressPath() string.
|
|
// Why: exposes startup progress path helper internals to top-level tests.
|
|
func (o *Orchestrator) TestHookStartupProgressPath() string {
|
|
return o.startupProgressPath()
|
|
}
|
|
|
|
// TestHookLastShutdownReportPath runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookLastShutdownReportPath() string.
|
|
// Why: exposes last-shutdown report path helper internals to top-level tests.
|
|
func (o *Orchestrator) TestHookLastShutdownReportPath() string {
|
|
return o.lastShutdownReportPath()
|
|
}
|
|
|
|
// TestHookBeginStartupReport runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookBeginStartupReport(reason string).
|
|
// Why: exposes startup-report bootstrap internals to top-level tests.
|
|
func (o *Orchestrator) TestHookBeginStartupReport(reason string) {
|
|
o.beginStartupReport(reason)
|
|
}
|
|
|
|
// TestHookSetStartupPhase runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookSetStartupPhase(phase string, detail string).
|
|
// Why: exposes startup phase progress tracking internals to top-level tests.
|
|
func (o *Orchestrator) TestHookSetStartupPhase(phase string, detail string) {
|
|
o.setStartupPhase(phase, detail)
|
|
}
|
|
|
|
// TestHookNoteStartupCheckState runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookNoteStartupCheckState(name string, status string, detail string).
|
|
// Why: exposes startup check-state tracking internals to top-level tests.
|
|
func (o *Orchestrator) TestHookNoteStartupCheckState(name string, status string, detail string) {
|
|
o.noteStartupCheckState(name, status, detail)
|
|
}
|
|
|
|
// TestHookNoteStartupCheck runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookNoteStartupCheck(name string, success bool, detail string).
|
|
// Why: exposes startup check convenience helper internals to top-level tests.
|
|
func (o *Orchestrator) TestHookNoteStartupCheck(name string, success bool, detail string) {
|
|
o.noteStartupCheck(name, success, detail)
|
|
}
|
|
|
|
// TestHookNoteStartupAutoHeal runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookNoteStartupAutoHeal(detail string).
|
|
// Why: exposes startup auto-heal report tracking internals to top-level tests.
|
|
func (o *Orchestrator) TestHookNoteStartupAutoHeal(detail string) {
|
|
o.noteStartupAutoHeal(detail)
|
|
}
|
|
|
|
// TestHookFinalizeStartupReport runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookFinalizeStartupReport(runErr error).
|
|
// Why: exposes startup report finalization internals to top-level tests.
|
|
func (o *Orchestrator) TestHookFinalizeStartupReport(runErr error) {
|
|
o.finalizeStartupReport(runErr)
|
|
}
|
|
|
|
// TestHookWriteStartupReportFileNil runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookWriteStartupReportFileNil(path string) error.
|
|
// Why: exposes nil-report writer branch to top-level tests.
|
|
func (o *Orchestrator) TestHookWriteStartupReportFileNil(path string) error {
|
|
return o.writeStartupReportFile(path, nil)
|
|
}
|
|
|
|
// TestHookWriteStartupReportFile runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookWriteStartupReportFile(path string, status string) error.
|
|
// Why: exposes startup-report writer error/success branches to top-level tests.
|
|
func (o *Orchestrator) TestHookWriteStartupReportFile(path string, status string) error {
|
|
report := &startupReport{
|
|
StartedAt: time.Now().UTC(),
|
|
Status: status,
|
|
Checks: map[string]startupCheckRecord{},
|
|
AutoHeals: []string{},
|
|
LastUpdated: time.Now().UTC(),
|
|
}
|
|
return o.writeStartupReportFile(path, report)
|
|
}
|
|
|
|
// TestHookPersistStartupProgressNil runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookPersistStartupProgressNil().
|
|
// Why: exposes startup-progress nil branch to top-level tests.
|
|
func (o *Orchestrator) TestHookPersistStartupProgressNil() {
|
|
o.persistStartupProgress(nil)
|
|
}
|
|
|
|
// TestHookPersistStartupProgress runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookPersistStartupProgress(status string).
|
|
// Why: exposes startup-progress persistence internals to top-level tests.
|
|
func (o *Orchestrator) TestHookPersistStartupProgress(status string) {
|
|
report := &startupReport{
|
|
StartedAt: time.Now().UTC(),
|
|
Status: status,
|
|
Checks: map[string]startupCheckRecord{},
|
|
AutoHeals: []string{},
|
|
LastUpdated: time.Now().UTC(),
|
|
}
|
|
o.persistStartupProgress(report)
|
|
}
|
|
|
|
// TestHookFinalizeRecord runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookFinalizeRecord(action string, reason string, runErr string).
|
|
// Why: exposes run-record finalization branches to top-level tests.
|
|
func (o *Orchestrator) TestHookFinalizeRecord(action string, reason string, runErr string) {
|
|
record := state.RunRecord{
|
|
ID: "hook-record-" + sanitizeReportFileName(action),
|
|
Action: action,
|
|
Reason: reason,
|
|
StartedAt: time.Now().UTC().Add(-3 * time.Second),
|
|
}
|
|
var err error
|
|
if runErr != "" {
|
|
err = errors.New(runErr)
|
|
}
|
|
o.finalizeRecord(&record, &err)
|
|
}
|
|
|
|
// TestHookFinalizeStartupReportSnapshot runs one orchestration or CLI step.
|
|
// Signature: (o *Orchestrator) TestHookFinalizeStartupReportSnapshot(runErr error) bool.
|
|
// Why: exposes snapshot finalizer internals to top-level tests without leaking private types.
|
|
func (o *Orchestrator) TestHookFinalizeStartupReportSnapshot(runErr error) bool {
|
|
report := &startupReport{
|
|
StartedAt: time.Now().UTC(),
|
|
Checks: map[string]startupCheckRecord{},
|
|
AutoHeals: []string{},
|
|
LastUpdated: time.Now().UTC(),
|
|
}
|
|
final := o.finalizeStartupReportSnapshot(report, runErr)
|
|
return final != nil
|
|
}
|