Navigation Menu

Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Dea Agent reads logs from apps that are starting
Browse files Browse the repository at this point in the history
Signed-off-by: Ruth Byers <rbyers@pivotallabs.com>
  • Loading branch information
matthewmcnew committed Feb 11, 2014
1 parent f9c0b7d commit 40aabec
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
19 changes: 19 additions & 0 deletions samples/starting_instances.json
@@ -0,0 +1,19 @@
{
"time": 1378422338.6501207,
"instances": [
{
"application_id": "e0e12b41-78d4-43ff-a5ae-20422bedf22f",
"state": "STARTING",
"warden_job_id": 12,
"instance_index": 0,
"warden_container_path": "/var/vcap/data/warden/depot/345asndhaena",
"warden_host_ip": "10.254.0.1",
"instance_host_port": 61001,
"instance_container_port": 61001,
"instance_id": "e2e76b2cfe370c7e213f2e3e36af621e",
"syslog_drain_urls": [

]
}
]
}
2 changes: 1 addition & 1 deletion src/deaagent/tasks_reader.go
Expand Up @@ -43,7 +43,7 @@ func readTasks(data []byte) (map[string]task, error) {
}
tasks := make(map[string]task, len(jsonInstances.Instances))
for _, jsonInstance := range jsonInstances.Instances {
if jsonInstance.State == "RUNNING" {
if jsonInstance.State == "RUNNING" || jsonInstance.State == "STARTING" {
task := task{
applicationId: jsonInstance.Application_id,
sourceName: "App",
Expand Down
15 changes: 15 additions & 0 deletions src/deaagent/tasks_reader_test.go
Expand Up @@ -86,6 +86,21 @@ func TestReadingMultipleTasksWithDrainUrls(t *testing.T) {
assert.Equal(t, tasks["/var/vcap/data/warden/depot/17fsdo7qpes/jobs/56"].drainUrls, []string{"syslog://10.20.30.40:8050"})
}

func TestReadingStartingTasks(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)
filepath := path.Join(path.Dir(filename), "..", "..", "samples", "starting_instances.json")
json, _ := ioutil.ReadFile(filepath)

tasks, err := readTasks(json)
assert.NoError(t, err)

assert.Equal(t, 1, len(tasks))

if _, ok := tasks["/var/vcap/data/warden/depot/345asndhaena/jobs/12"]; !ok {
t.Errorf("Did not find starting application.")
}
}

func TestErrorHandlingWhenParsingEmptyData(t *testing.T) {
_, err := readTasks(make([]byte, 0))
assert.Error(t, err)
Expand Down

0 comments on commit 40aabec

Please sign in to comment.