func TestGetProcessesWithDeployments(t *testing.T) { os.Setenv("RACK", "convox-test") os.Setenv("CLUSTER", "convox-test-cluster") aws := test.StubAws( test.DescribeAppStackCycle("convox-test-myapp-staging"), test.DescribeAppStackCycle("convox-test-myapp-staging"), test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"), test.ListContainerInstancesCycle("convox-test-cluster"), test.DescribeContainerInstancesCycle("convox-test-cluster"), test.DescribeInstancesCycle(), test.ListTasksCycle("convox-test-cluster", "convox-test-myapp-staging-worker-SCELGCIYSKF"), test.DescribeTasksCycle("convox-test-cluster"), test.ListTasksOneoffEmptyCycle("convox-test-cluster"), test.DescribeTaskDefinitionCycle("convox-test-cluster"), test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"), test.DescribeServicesWithDeploymentsCycle("convox-test-cluster"), test.DescribeTaskDefinition3Cycle("convox-test-cluster"), test.DescribeTaskDefinition1Cycle("convox-test-cluster"), ) defer aws.Close() docker := test.StubDocker( // query for every ECS task to get docker id, command, created test.ListECSContainersCycle(), // query every instance for one-off containers test.ListOneoffContainersEmptyCycle(), test.ListOneoffContainersEmptyCycle(), test.ListOneoffContainersEmptyCycle(), // query for every container to get CPU and Memory stats test.StatsCycle(), ) defer docker.Close() v := url.Values{} v.Add("stats", "true") body := test.HTTPBody("GET", "http://convox/apps/myapp-staging/processes", v) var resp client.Processes err := json.Unmarshal([]byte(body), &resp) if assert.Nil(t, err) { assert.Equal(t, 2, len(resp)) assert.Equal(t, "8dfafdbc3a40", resp[0].Id) assert.Equal(t, 0.0974, resp[0].Memory) assert.Equal(t, "pending", resp[1].Id) assert.EqualValues(t, 0, resp[1].Memory) } }
func TestGetProcessesWithDeployments(t *testing.T) { os.Setenv("RACK", "convox-test") os.Setenv("CLUSTER", "convox-test-cluster") os.Setenv("TEST", "true") aws := test.StubAws( test.DescribeAppStackCycle("myapp-staging"), test.DescribeAppStackCycle("myapp-staging"), test.ListTasksCycle("convox-test-cluster"), test.DescribeTasksCycle("convox-test-cluster"), test.DescribeTaskDefinitionCycle("convox-test-cluster"), test.DescribeContainerInstancesFilteredCycle("convox-test-cluster"), test.DescribeInstancesFilteredCycle(), test.DescribeAppStackResourcesCycle("myapp-staging"), test.DescribeServicesWithDeploymentsCycle("convox-test-cluster"), test.DescribeTaskDefinition3Cycle("convox-test-cluster"), test.ListContainerInstancesCycle("convox-test-cluster"), test.DescribeContainerInstancesCycle("convox-test-cluster"), test.DescribeInstancesCycle(), test.DescribeTaskDefinition1Cycle("convox-test-cluster"), ) defer aws.Close() docker := test.StubDocker( test.ListContainersCycle(), test.ListConvoxContainersCycle(), test.ListConvoxContainersCycle(), test.ListConvoxContainersCycle(), test.StatsCycle(), ) defer docker.Close() v := url.Values{} v.Add("stats", "false") body := test.HTTPBody("GET", "http://convox/apps/myapp-staging/processes", v) var resp client.Processes err := json.Unmarshal([]byte(body), &resp) if assert.Nil(t, err) { assert.Equal(t, 2, len(resp)) assert.Equal(t, "pending", resp[1].Id) //assert.Equal(t, "8dfafdbc3a40", resp[1].Id) //assert.Equal(t, "8dfafdbc3a40", resp[2].Id) //assert.Equal(t, "4932cce0897b", resp[3].Id) //assert.Equal(t, "pending", resp[4].Id) } }
func TestGetProcessesWithDeployments(t *testing.T) { // set current provider testProvider := &provider.TestProviderRunner{ Instances: []structs.Instance{ structs.Instance{}, structs.Instance{}, structs.Instance{}, }, } provider.CurrentProvider = testProvider defer func() { //TODO: remove: as we arent updating all tests we need tos et current provider back to a //clean default one (I miss rspec before) provider.CurrentProvider = new(provider.TestProviderRunner) }() // setup expectations on current provider testProvider.On("InstanceList").Return(testProvider.Instances, nil) os.Setenv("RACK", "convox-test") os.Setenv("CLUSTER", "convox-test-cluster") aws := test.StubAws( test.DescribeAppStackCycle("convox-test-myapp-staging"), test.DescribeAppStackCycle("convox-test-myapp-staging"), test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"), test.ListContainerInstancesCycle("convox-test-cluster"), test.DescribeContainerInstancesCycle("convox-test-cluster"), test.DescribeInstancesCycle(), test.ListTasksCycle("convox-test-cluster", "convox-test-myapp-staging-worker-SCELGCIYSKF"), test.DescribeTasksCycle("convox-test-cluster"), test.ListTasksOneoffEmptyCycle("convox-test-cluster"), test.DescribeTaskDefinitionCycle("convox-test-cluster"), test.DescribeAppStackResourcesCycle("convox-test-myapp-staging"), test.DescribeServicesWithDeploymentsCycle("convox-test-cluster"), test.DescribeTaskDefinition3Cycle("convox-test-cluster"), test.DescribeTaskDefinition1Cycle("convox-test-cluster"), ) defer aws.Close() docker := test.StubDocker( // query for every ECS task to get docker id, command, created test.ListECSContainersCycle(), // query every instance for one-off containers test.ListOneoffContainersEmptyCycle(), test.ListOneoffContainersEmptyCycle(), test.ListOneoffContainersEmptyCycle(), // query for every container to get CPU and Memory stats test.StatsCycle(), ) defer docker.Close() v := url.Values{} v.Add("stats", "true") body := test.HTTPBody("GET", "http://convox/apps/myapp-staging/processes", v) var resp client.Processes err := json.Unmarshal([]byte(body), &resp) if assert.Nil(t, err) { assert.Equal(t, 2, len(resp)) assert.Equal(t, "8dfafdbc3a40", resp[0].Id) assert.Equal(t, 0.0974, resp[0].Memory) assert.Equal(t, "pending", resp[1].Id) assert.EqualValues(t, 0, resp[1].Memory) } }