Пример #1
0
func logCommands(commands []*protoeasy.Command) {
	for _, command := range commands {
		if len(command.Arg) > 0 {
			protolog.Infof("\n%s\n", strings.Join(command.Arg, " \\\n\t"))
		}
	}
}
Пример #2
0
func waitForJob(t *testing.T, jobAPIClient pps.JobAPIClient, job *pps.Job, timeoutSec int, expectError bool) *pps.JobInfo {
	for i := 0; i < timeoutSec; i++ {
		time.Sleep(1 * time.Second)
		jobInfo, err := jobAPIClient.InspectJob(
			context.Background(),
			&pps.InspectJobRequest{
				Job: job,
			},
		)
		require.NoError(t, err)
		if len(jobInfo.JobStatus) == 0 {
			continue
		}
		jobStatus := jobInfo.JobStatus[0]
		protolog.Infof("status of job %s at %d seconds: %v", job.Id, i+1, jobInfo.JobStatus)
		switch jobStatus.Type {
		case pps.JobStatusType_JOB_STATUS_TYPE_ERROR:
			handleEndJobStatus(t, jobAPIClient, jobInfo)
			if !expectError {
				t.Fatalf("job %s had error", job.Id)
			}
			return jobInfo
		case pps.JobStatusType_JOB_STATUS_TYPE_SUCCESS:
			handleEndJobStatus(t, jobAPIClient, jobInfo)
			if expectError {
				t.Fatalf("job %s did not have error", job.Id)
			}
			return jobInfo
		}
	}
	t.Fatalf("job %s did not finish in %d seconds", job.Id, timeoutSec)
	return nil
}
Пример #3
0
func testNodeFunc(counter *int32, intC chan int, nodeName string, i int, errString string) func() error {
	var err error
	if errString != "" {
		err = errors.New(errString)
	}
	return func() error {
		atomic.AddInt32(counter, 1)
		intC <- i
		protolog.Infof("ran %s, sent %d, returning %v\n", nodeName, i, err)
		return err
	}
}