// ExpectProgMetricDeltaWithDeadline tests that a given program metric increases by want within the deadline.  It assumes that the named metric is an Int type datum.Datum.
ExpectProgMetricDeltaWithDeadline tests that a given program metric increases by want within the deadline.  It assumes that the named metric is an Int type datum.Datum.
// ExpectProgMetricDeltaWithDeadline tests that a given program metric increases by want within the deadline . It assumes that the named metric is an Int type datum . Datum .
func (ts *TestServer) ExpectProgMetricDeltaWithDeadline(name, prog string, want int64) func() {
	ts.tb.Helper()
	deadline := ts.DoOrTimeoutDeadline
	if deadline == 0 {
		deadline = defaultDoOrTimeoutDeadline
	}
	start := datum.GetInt(ts.GetProgramMetric(name, prog))
	check := func() (bool, error) {
		ts.tb.Helper()
		now := datum.GetInt(ts.GetProgramMetric(name, prog))
		return now-start == want, nil
	}
	return func() {
		ts.tb.Helper()
		ok, err := testutil.DoOrTimeout(check, deadline, 10*time.Millisecond)
		if err != nil {
			ts.tb.Fatal(err)
		}
		if !ok {
			now := datum.GetInt(ts.GetProgramMetric(name, prog))
			delta := now - start
			ts.tb.Errorf("Did not see %s have delta by deadline: got %v - %v = %d, want %d", name, now, start, delta, want)
		}
	}
}
func ( ts * TestServer ) ExpectProgMetricDeltaWithDeadline ( name , prog string , want int64 ) func ( ) { ts . tb . Helper ( ) deadline := ts . DoOrTimeoutDeadline if deadline == 0 { deadline = defaultDoOrTimeoutDeadline } start := datum . GetInt ( ts . GetProgramMetric ( name , prog ) ) check := func ( ) ( bool , error ) { ts . tb . Helper ( ) now := datum . GetInt ( ts . GetProgramMetric ( name , prog ) ) return now - start == want , nil } return func ( ) { ts . tb . Helper ( ) ok , err := testutil . DoOrTimeout ( check , deadline , 10 * time . Millisecond ) if err != nil { ts . tb . Fatal ( err ) } if ! ok { now := datum . GetInt ( ts . GetProgramMetric ( name , prog ) ) delta := now - start ts . tb . Errorf ( " " , name , now , start , delta , want ) } } }
ExpectProgMetricDeltaWithDeadline tests that a given program metric increases by want within the deadline.
ExpectProgMetricDeltaWithDeadline tests that a given program metric increases by want within the deadline .