Ejemplo n.º 1
0
func TestCreateMarathon(t *testing.T) {
	tests := []struct {
		params        map[string]interface{}
		expectedError bool
		desc          string
	}{
		{map[string]interface{}{"address": "https://localhost:8081/v2"}, true, "Should fail, needs deploy-timeout"},
		{map[string]interface{}{"deploy-timeout": 1}, true, "Should fail, needs address"},
		{map[string]interface{}{"address": "nonsense://localhost:8081/v2", "deploy-timeout": 1}, true, "Should fail, invalid address"},
		{map[string]interface{}{"address": "https://localhost:8081/v2", "deploy-timeout": 1}, false, "Should be a valid framework"},
		{map[string]interface{}{"address": "https://localhost:8081/v2", "deploy-timeout": 1, "docker-cfg": "file:///home/test/.myDockerConfig"}, false, "Should be a valid framework"},
		{map[string]interface{}{"address": "https://localhost:8081/v2", "deploy-timeout": 1, "basic-auth-user": "******", "basic-auth-pwd": "pass"}, false, "Should be a valid framework"},
		{map[string]interface{}{"address": "https://localhost:8081/v2", "deploy-timeout": 1, "basic-auth-user": "******"}, true, "Should fail, needs basic-auth-user and basic-auth-pwd"},
		{map[string]interface{}{"address": "https://localhost:8081/v2", "deploy-timeout": 1, "basic-auth-pwd": "pass"}, true, "Should fail, needs basic-auth-user and basic-auth-pwd"},
		{map[string]interface{}{
			"address":                               "https://localhost:8081/v2",
			"deploy-timeout":                        1,
			"health-check-grace-period":             30,
			"health-check-interval":                 20,
			"health-check-max-consecutive-failures": "3",
			"health-check-timeout":                  10,
		}, false, "Should be a valid framework"},
	}
	for _, v := range tests {
		clusterFramework, err := factory.Create("marathon", v.params)
		if v.expectedError {
			assert.Error(t, err, v.desc)
			assert.Nil(t, clusterFramework)
		} else {
			assert.Nil(t, err)
			assert.NotNil(t, clusterFramework, v.desc)
			assert.Equal(t, "marathon", clusterFramework.ID(), "Should be Marathon")
		}
	}
}
Ejemplo n.º 2
0
func TestLogMetadata(t *testing.T) {
	paramMap := map[string]interface{}{
		"address":        "https://localhost:8081/v2",
		"deploy-timeout": 1,
		"log-metadata":   map[string]interface{}{"clusterKey": "clusterVal"},
	}
	clusterFramework, _ := factory.Create("marathon", paramMap)
	assert.Equal(t, "clusterVal", clusterFramework.(*Marathon).logEntry.Data["clusterKey"], "Invalid log-metadata, should be clusterVal")
	assert.Equal(t, nil, clusterFramework.(*Marathon).logEntry.Data["foo"], "foo log-metadata, should be nil")
}