Example #1
0
File: stack.go Project: ch3lo/crane
func NewStack(stackKey string, stackNofitication chan<- StackStatus, config configuration.Cluster) (StackInterface, error) {
	if config.Disabled {
		return nil, &ClusterDisabled{Name: stackKey}
	}

	clusterScheduler, err := factory.Create(config.Framework.Type(), config.Framework.Parameters())
	if err != nil {
		return nil, fmt.Errorf("Error creating framework %s in %s. %s", config.Framework.Type(), stackKey, err.Error())
	}
	s := new(Stack)
	s.id = stackKey
	s.stackNofitication = stackNofitication
	s.frameworkApiHelper = clusterScheduler
	s.serviceIdNotification = make(chan string, 1000)

	util.Log.WithFields(log.Fields{
		"stack": stackKey,
	}).Infof("A new framework was created: %s", config.Framework.Type())

	return s, nil
}
func (suite *MarathonSuite) TestLogMetadata() {
	suite.paramMap["log-metadata"] = map[string]interface{}{"clusterKey": "clusterVal"}
	clusterFramework, _ := factory.Create("marathon", suite.paramMap)
	assert.Equal(suite.T(), "clusterVal", clusterFramework.(*Marathon).logEntry.Data["clusterKey"], "Invalid log-metadata, should be clusterVal")
	assert.Equal(suite.T(), nil, clusterFramework.(*Marathon).logEntry.Data["foo"], "foo log-metadata, should be nil")
}
func (suite *MarathonSuite) assertErrorOnCreate() {
	_, err := factory.Create("marathon", suite.paramMap)
	assert.NotNil(suite.T(), err, "Should throw error")
}
func (suite *MarathonSuite) TestCreateMarathonWithBasicAuth() {
	m, _ := factory.Create("marathon", suite.paramMap)
	assert.NotNil(suite.T(), m, "Should return healthy framework")
}
func (suite *MarathonSuite) assertCreateFramework() {
	clusterFramework, _ := factory.Create("marathon", suite.paramMap)
	assert.Equal(suite.T(), "marathon", clusterFramework.ID(), "Should be Marathon")
}