Exemplo n.º 1
0
func TestOutputTruncation(t *testing.T) {
	out := contracts.PluginOutput{
		Stdout:   "standard output of test case",
		Stderr:   "standard error of test case",
		ExitCode: 0,
		Status:   "Success",
	}
	response := contracts.TruncateOutput(out.Stdout, out.Stderr, 200)
	fmt.Printf("response=\n%v\n", response)
	assert.Equal(t, out.String(), response)

}
Exemplo n.º 2
0
// prepareRuntimeStatus creates the structure for the runtimeStatus section of the payload of SendReply
// for a particular plugin.
func prepareRuntimeStatus(update *UpdateDetail) contracts.PluginRuntimeStatus {
	// Set default as failed, this will help us catch issues more proactively
	pluginStatus := update.Result
	code := 0
	if pluginStatus == contracts.ResultStatusFailed {
		code = 1
	}

	output := contracts.TruncateOutput(update.StandardOut,
		update.StandardError,
		contracts.MaximumPluginOutputSize)

	return contracts.PluginRuntimeStatus{
		Code:               code,
		Status:             pluginStatus,
		Output:             output,
		OutputS3BucketName: update.OutputS3BucketName,
		OutputS3KeyPrefix:  update.OutputS3KeyPrefix,
		StartDateTime:      times.ToIso8601UTC(update.StartDateTime),
		EndDateTime:        times.ToIso8601UTC(time.Now()),
	}
}