Example #1
0
func TestLoadBalancerNameUniquePerEntryWithTruncation(t *testing.T) {
	mb1 := ManifestBalancer{
		Entry: ManifestEntry{
			app: &App{
				Name: "myverylogappname-production",
			},
			Name: "web",
		},
		Public: true,
	}

	mb2 := ManifestBalancer{
		Entry: ManifestEntry{
			app: &App{
				Name: "myverylogappname-production",
			},
			Name: "worker",
		},
		Public: true,
	}

	assert.EqualValues(t, `"myverylogappname-product-DIVTGA7"`, mb1.LoadBalancerName())
	assert.EqualValues(t, `"myverylogappname-product-LQYILNJ"`, mb2.LoadBalancerName())

	assert.Equal(t, 34, len(mb1.LoadBalancerName())) // ELB name is max 32 characters + quotes

	mb1.Public = false
	mb2.Public = false

	assert.EqualValues(t, `"myverylogappname-produ-DIVTGA7-i"`, mb1.LoadBalancerName())
	assert.EqualValues(t, `"myverylogappname-produ-LQYILNJ-i"`, mb2.LoadBalancerName())

	assert.Equal(t, 34, len(mb1.LoadBalancerName())) // ELB name is max 32 characters + quotes
}
Example #2
0
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)
	}
}
Example #3
0
func TestLoadBalancerNameUniquePerRack(t *testing.T) {
	// reset RACK after this test
	r := os.Getenv("RACK")
	defer os.Setenv("RACK", r)

	mb := ManifestBalancer{
		Entry: ManifestEntry{
			app: &App{
				Name: "foo",
			},
			Name: "web",
		},
	}

	os.Setenv("RACK", "staging")
	assert.EqualValues(t, `"foo-web-GSAGMQZ-i"`, mb.LoadBalancerName())

	os.Setenv("RACK", "production")
	assert.EqualValues(t, `"foo-web-7MS5NPT-i"`, mb.LoadBalancerName())
}
Example #4
0
// EqualValues asserts that two objects are equal or convertable to the same types
// and equal.
//
//    assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal")
//
// Returns whether the assertion was successful (true) or not (false).
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
	if !assert.EqualValues(t, expected, actual, msgAndArgs...) {
		t.FailNow()
	}
}