MCPcopy Create free account
hub / github.com/facebook/time / TestDaemonDoWork

Function TestDaemonDoWork

fbclock/daemon/daemon_test.go:503–673  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

501 SmearingEndS: 1483291336,
502 UTCOffsetPreS: 36,
503 UTCOffsetPostS: 37,
504 }
505 require.NoError(t, err)
506 require.Equal(t, want, shmData)
507
508 // no leap second data
509 leaps = []leapsectz.LeapSecond{}
510 d = &DataPoint{
511 IngressTimeNS: int64(startTime + 66*time.Second),
512 MasterOffsetNS: 234,
513 PathDelayNS: 213,
514 FreqAdjustmentPPB: 32333,
515 ClockAccuracyNS: 100,
516 ServoState: 2,
517 }
518 shmData, err = s.calculateSHMData(d, leaps)
519 want = &fbclock.Data{
520 IngressTimeNS: d.IngressTimeNS,
521 ErrorBoundNS: 185,
522 HoldoverMultiplierNS: 9361.241379310344,
523 SmearingStartS: 0,
524 SmearingEndS: 0,
525 UTCOffsetPreS: 0,
526 UTCOffsetPostS: 0,
527 }
528 require.NoError(t, err)
529 require.Equal(t, want, shmData)
530}
531
532func TestDaemonDoWork(t *testing.T) {
533 cfg := &Config{
534 Interval: time.Second,
535 RingSize: 30,
536 Math: Math{
537 M: "mean(clockaccuracy, 30) + abs(mean(offset, 30)) + 1.0 * stddev(offset, 30)",
538 W: "mean(m, 30) + 4.0 * stddev(m, 30)",
539 Drift: "1.5 * mean(freqchangeabs, 29)",
540 },
541 }
542 err := cfg.Math.Prepare()
543 require.NoError(t, err)
544 stats := stats.NewStats()
545 s := newTestDaemon(cfg, stats)
546 startTime := time.Duration(1647359186979431900)
547 phcTime := startTime // we modify this during the test
548 // override function to get PHC time
549 s.getPHCTime = func() (time.Time, error) { return time.Unix(0, int64(phcTime)), nil }
550 // shared mem
551 tmpFile, err := os.CreateTemp("", "daemon_test")
552 require.NoError(t, err)
553 defer os.Remove(tmpFile.Name())
554 shm, err := fbclock.OpenFBClockShmCustomVer(tmpFile.Name(), 1)
555 require.NoError(t, err)
556 defer shm.Close()
557
558 // populate the data
559 var d *DataPoint
560

Callers

nothing calls this directly

Calls 13

GetMethod · 0.95
OpenFBClockShmCustomVerFunction · 0.92
MmapShmpDataV1Function · 0.92
ReadFBClockDataV1Function · 0.92
newTestDaemonFunction · 0.85
PrepareMethod · 0.80
UnixMethod · 0.80
doWorkMethod · 0.80
NameMethod · 0.65
CloseMethod · 0.65
FdMethod · 0.65
DurationMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…