mirror of
https://github.com/spaytac/orbiter.git
synced 2026-01-21 23:54:41 +00:00
Fixed #9 This PR bootstrap the autodetection feature: 1. It works when the configuration file is not setup. Right know I am not going to manage the merge of double sources (autodetection and configuration file). 2. At the moment only Docker Swarm will support this feature.
97 lines
1.8 KiB
Go
97 lines
1.8 KiB
Go
package core
|
|
|
|
import "testing"
|
|
|
|
func TestNewCore(t *testing.T) {
|
|
conf := map[string]AutoscalerConf{
|
|
"first-scaler": AutoscalerConf{
|
|
Provider: "fake",
|
|
Parameters: map[string]string{},
|
|
Policies: map[string]PolicyConf{
|
|
"frontend": PolicyConf{
|
|
Up: 3,
|
|
Down: 10,
|
|
},
|
|
},
|
|
},
|
|
"second-scaler": AutoscalerConf{
|
|
Provider: "fake",
|
|
Parameters: map[string]string{},
|
|
Policies: map[string]PolicyConf{
|
|
"micro": PolicyConf{
|
|
Up: 6,
|
|
Down: 2,
|
|
},
|
|
"service": PolicyConf{
|
|
Up: 3,
|
|
Down: 1,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
core, err := NewCoreByConfig(conf)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(core.Autoscalers) != 3 {
|
|
t.Fatalf("This core needs to have 2 autoscalers. Not %d", len(core.Autoscalers))
|
|
}
|
|
}
|
|
|
|
func TestGetSingleAutoscaler(t *testing.T) {
|
|
conf := map[string]AutoscalerConf{
|
|
"second": AutoscalerConf{
|
|
Provider: "fake",
|
|
Parameters: map[string]string{},
|
|
Policies: map[string]PolicyConf{
|
|
"micro": PolicyConf{
|
|
Up: 6,
|
|
Down: 2,
|
|
},
|
|
"service": PolicyConf{
|
|
Up: 3,
|
|
Down: 1,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
core, _ := NewCoreByConfig(conf)
|
|
_, ok := core.Autoscalers["second/micro"]
|
|
if ok == false {
|
|
t.Fatal("micro exist")
|
|
}
|
|
}
|
|
|
|
func TestNewCoreWithUnsupportedProvider(t *testing.T) {
|
|
conf := map[string]AutoscalerConf{
|
|
"second-scaler": AutoscalerConf{
|
|
Provider: "fake",
|
|
Parameters: map[string]string{},
|
|
Policies: map[string]PolicyConf{
|
|
"micro": PolicyConf{
|
|
Up: 6,
|
|
Down: 2,
|
|
},
|
|
"service": PolicyConf{
|
|
Up: 3,
|
|
Down: 1,
|
|
},
|
|
},
|
|
},
|
|
"first-scaler": AutoscalerConf{
|
|
Provider: "lalala",
|
|
Parameters: map[string]string{},
|
|
Policies: map[string]PolicyConf{
|
|
"frontend": PolicyConf{
|
|
Up: 3,
|
|
Down: 10,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
_, err := NewCoreByConfig(conf)
|
|
if err.Error() != "lalala not supported." {
|
|
t.Fatal(err)
|
|
}
|
|
}
|