Exemple #1
0
// post count=0 should set MainDesiredCount=0 in the stack update
func TestFormationScaleCount0(t *testing.T) {
	// set current provider
	testProvider := &provider.TestProviderRunner{
		Capacity: structs.Capacity{},
	}
	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("CapacityGet").Return(testProvider.Capacity, nil)

	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
		test.GetItemAppReleaseCycle("convox-test-application"),
		test.UpdateAppStackCycle("convox-test-application", "0", "256"),
	)
	defer aws.Close()

	val := url.Values{"count": []string{"0"}, "memory": []string{""}}
	body := test.HTTPBody("POST", "http://convox/apps/application/formation/main", val)

	assert.Equal(t, `{"success":true}`, body)
}
Exemple #2
0
// post memory=2048 should error
func TestFormationScaleMemory2048(t *testing.T) {
	// set current provider
	testProvider := &provider.TestProviderRunner{
		Capacity: structs.Capacity{
			InstanceMemory: 1024,
		},
	}
	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)
	}()
	testProvider.On("CapacityGet").Return(testProvider.Capacity, nil)

	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
		test.GetItemAppReleaseCycle("convox-test-application"),
		test.UpdateAppStackCycle("convox-test-application", "1", "512"),
	)
	defer aws.Close()

	provider.TestProvider.Capacity = structs.Capacity{
		InstanceMemory: 1024,
	}

	val := url.Values{"count": []string{""}, "memory": []string{"2048"}}
	body := test.HTTPBody("POST", "http://convox/apps/application/formation/main", val)

	assert.Equal(t, `{"error":"requested memory 2048 greater than instance size 1024"}`, body)
}
Exemple #3
0
// post memory=foo should 403
func TestFormationScaleMemoryInvalid(t *testing.T) {
	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
		test.GetItemAppReleaseCycle("convox-test-application"),
		test.UpdateAppStackCycle("convox-test-application", "1", "256"),
	)
	defer aws.Close()

	val := url.Values{"count": []string{""}, "memory": []string{"foo"}}
	body := test.HTTPBody("POST", "http://convox/apps/application/formation/main", val)

	assert.Equal(t, `{"error":"memory must be numeric"}`, body)
}
Exemple #4
0
// post count=0 should set MainDesiredCount=0 in the stack update
func TestFormationScaleCount0(t *testing.T) {
	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
		test.GetItemAppReleaseCycle("convox-test-application"),
		test.UpdateAppStackCycle("convox-test-application", "0", "256"),
	)
	defer aws.Close()

	val := url.Values{"count": []string{"0"}, "memory": []string{""}}
	body := test.HTTPBody("POST", "http://convox/apps/application/formation/main", val)

	assert.Equal(t, `{"success":true}`, body)
}
Exemple #5
0
// post memory=2048 should error
func TestFormationScaleMemory2048(t *testing.T) {
	aws := test.StubAws(
		test.DescribeAppStackCycle("convox-test-application"),
		test.DescribeAppStackCycle("convox-test-application"),
		test.GetItemAppReleaseCycle("convox-test-application"),
		test.UpdateAppStackCycle("convox-test-application", "1", "512"),
	)
	defer aws.Close()

	provider.TestProvider.Capacity = structs.Capacity{
		InstanceMemory: 1024,
	}

	val := url.Values{"count": []string{""}, "memory": []string{"2048"}}
	body := test.HTTPBody("POST", "http://convox/apps/application/formation/main", val)

	assert.Equal(t, `{"error":"requested memory 2048 greater than instance size 1024"}`, body)
}