예제 #1
0
func TestIdentifier(t *testing.T) {
	task := domain.Task{
		ApplicationId:       "4aa9506e-277f-41ab-b764-a35c0b96fa1b",
		WardenJobId:         272,
		WardenContainerPath: "/var/vcap/data/warden/depot/16vbs06ibo1"}

	assert.Equal(t, "/var/vcap/data/warden/depot/16vbs06ibo1/jobs/272", task.Identifier())
}
예제 #2
0
func NewTaskListener(task domain.Task, e emitter.Emitter, logger *gosteno.Logger) *TaskListener {
	return &TaskListener{
		Logger:         logger,
		emitter:        e,
		taskIdentifier: task.Identifier(),
		stdOutListener: loggingstream.NewLoggingStream(&task, logger, logmessage.LogMessage_OUT),
		stdErrListener: loggingstream.NewLoggingStream(&task, logger, logmessage.LogMessage_ERR),
	}
}
예제 #3
0
func setupSockets(t *testing.T, task *domain.Task) (net.Listener, net.Listener) {
	stdoutSocketPath := filepath.Join(task.Identifier(), "stdout.sock")
	stderrSocketPath := filepath.Join(task.Identifier(), "stderr.sock")
	os.Remove(stdoutSocketPath)
	os.Remove(stderrSocketPath)
	stdoutListener, err := net.Listen("unix", stdoutSocketPath)
	assert.NoError(t, err)
	stderrListener, err := net.Listen("unix", stderrSocketPath)
	assert.NoError(t, err)
	return stdoutListener, stderrListener
}
예제 #4
0
func NewTaskListener(task domain.Task, logger *gosteno.Logger) (*TaskListener, error) {
	stdOutReader, err := dial(task.Identifier(), events.LogMessage_OUT, logger)
	if err != nil {
		return nil, errors.New(fmt.Sprintf("Connection to stdout %s failed\n", task.Identifier()))
	}
	stdErrReader, err := dial(task.Identifier(), events.LogMessage_ERR, logger)
	if err != nil {
		stdOutReader.Close()
		return nil, errors.New(fmt.Sprintf("Connection to stderr %s failed\n", task.Identifier()))
	}
	return &TaskListener{
		Logger:         logger,
		taskIdentifier: task.Identifier(),
		stdOutReader:   stdOutReader,
		stdErrReader:   stdErrReader,
		task:           task,
	}, nil
}
예제 #5
0
func setupTaskSockets(task *domain.Task) (stdout net.Listener, stderr net.Listener) {
	os.MkdirAll(task.Identifier(), 0777)
	stdoutSocketPath := filepath.Join(task.Identifier(), "stdout.sock")
	os.Remove(stdoutSocketPath)
	stdoutListener, _ := net.Listen("unix", stdoutSocketPath)

	stderrSocketPath := filepath.Join(task.Identifier(), "stderr.sock")
	os.Remove(stderrSocketPath)
	stderrListener, _ := net.Listen("unix", stderrSocketPath)
	return stdoutListener, stderrListener
}
예제 #6
0
func setupTaskSockets(task *domain.Task) (stdout net.Listener, stderr net.Listener) {
	err := os.MkdirAll(task.Identifier(), 0777)
	Expect(err).NotTo(HaveOccurred())
	stdoutSocketPath := filepath.Join(task.Identifier(), "stdout.sock")
	_ = os.Remove(stdoutSocketPath)

	stdoutListener, err := net.Listen("unix", stdoutSocketPath)
	Expect(err).NotTo(HaveOccurred())

	stderrSocketPath := filepath.Join(task.Identifier(), "stderr.sock")
	_ = os.Remove(stderrSocketPath)
	stderrListener, err := net.Listen("unix", stderrSocketPath)
	Expect(err).NotTo(HaveOccurred())

	return stdoutListener, stderrListener
}
예제 #7
0
package domain_test

import (
	"deaagent/domain"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Task", func() {
	It("sets identifier correctly", func() {
		task := domain.Task{
			ApplicationId:       "4aa9506e-277f-41ab-b764-a35c0b96fa1b",
			WardenJobId:         272,
			WardenContainerPath: "/var/vcap/data/warden/depot/16vbs06ibo1"}

		Expect(task.Identifier()).To(Equal("/var/vcap/data/warden/depot/16vbs06ibo1/jobs/272"))
	})
})