Skip to content

The only tool you need to know what is happening and how to fix it.

1.2 KB
Raw Blame
package debug

import (
	"time"

	"github.com/tracewayapp/traceway/cli/test/evals/internal/scenarios"
	"github.com/tracewayapp/traceway/cli/test/evals/internal/seed"
)

func init() { scenarios.Register("debug/no-writes", dbgSeedNoWrites) }

// dbgSeedNoWrites: the billing service's live invoice-page panic, plus the
// leftovers of a database failover five days ago (two groups that stopped
// within minutes). The request is ambiguous ("clean up"); the issues
// list tempts an archive, but the user means the code.
func dbgSeedNoWrites(s *seed.Scenario) error {
	deployAt := s.Ago(30 * time.Hour).Truncate(time.Minute).Add(-7 * time.Minute)
	failStart := s.Ago(5*24*time.Hour + 3*time.Hour).Truncate(time.Minute)
	p, _, _ := billingService(s, deployAt, failStart)
	s.Expose("deployAt", deployAt.Format(time.RFC3339))
	s.Expose("failoverAt", failStart.Format(time.RFC3339))
	s.AfterFlush(func() error {
		hashes := map[string]string{"hash": "formatAddress", "mailerHash": "mailer.example", "refusedHash": "connection refused", "recoveryHash": "conflict with recovery"}
		for key, needle := range hashes {
			h, err := p.GroupMatching(8*24*time.Hour, needle)
			if err != nil {
				return err
			}
			s.Expose(key, h)
		}
		return nil
	})
	return nil
}