Beispiel #1
0
// finishWorkUnit marks a specific work unit as finished.
func finishWorkUnit(t *testing.T, j *jobserver.JobServer, workSpecName, workUnitKey string, data map[string]interface{}) {
	options := map[string]interface{}{
		"status": jobserver.Finished,
	}
	if data != nil {
		options["data"] = data
	}
	ok, msg, err := j.UpdateWorkUnit(workSpecName, workUnitKey, options)
	if assert.NoError(t, err) {
		assert.True(t, ok)
		assert.Empty(t, msg)
	}
}
Beispiel #2
0
func prepareSomeOfEach(t *testing.T, j *jobserver.JobServer, n int) (workSpecName string, expected map[string]map[string]interface{}) {
	data := map[string]interface{}{"x": 1}
	expected = map[string]map[string]interface{}{}
	workSpecName = setWorkSpec(t, j, WorkSpecData)

	for _, name := range []string{"FA", "IL"}[:n] {
		addWorkUnit(t, j, workSpecName, name, data)
		getSpecificWork(t, j, workSpecName, name)
		ok, msg, err := j.UpdateWorkUnit(workSpecName, name, map[string]interface{}{"status": jobserver.Failed})
		if assert.NoError(t, err) {
			assert.True(t, ok)
			assert.Empty(t, msg)
		}
		expected[name] = data
	}

	for _, name := range []string{"FI", "NI"}[:n] {
		addWorkUnit(t, j, workSpecName, name, data)
		getSpecificWork(t, j, workSpecName, name)
		finishWorkUnit(t, j, workSpecName, name, nil)
		expected[name] = data
	}

	for _, name := range []string{"PE", "ND"}[:n] {
		addWorkUnit(t, j, workSpecName, name, data)
		getSpecificWork(t, j, workSpecName, name)
		expected[name] = data
	}

	for _, name := range []string{"AV", "AI"}[:n] {
		addWorkUnit(t, j, workSpecName, name, data)
		expected[name] = data
	}

	return
}