func Test_ConfigService(t *testing.T) {

	cfg, err := config.LoadConfig(testConfigFile)
	if err != nil {
		t.Fatalf("%s", err)
	}
	cfg.Http.ClientConf = testUIConfigFile
	t.Logf("Endpoint: %s", cfg.Http.Endpoints.Config)

	go func() {

		if _, err = NewConfigService(cfg, nil); err != nil {
			t.Fatalf("%s", err)
		}
		http.ListenAndServe(":3456", nil)
	}()
	time.Sleep(3)
	resp, err := http.Get("http://localhost:3456/api/config")
	if err != nil {
		t.Fatalf("%s", err)
	}

	defer resp.Body.Close()
	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		t.Fatalf("%s", err)
	}

	if resp.StatusCode != 200 {
		t.Fatalf("Wrong status code: %d %s", resp.StatusCode, b)
	}

	t.Logf("%s", b)

}
func Test_LoadDatastore(t *testing.T) {
	testConfig, _ = config.LoadConfig(testConfigFile)
	testConfig.Datastore.TypeConfig["mapping_file"] = testEssMapFile

	ds, err := LoadDatastore(&testConfig.Datastore, simplelog.NewStdLogger())
	if err != nil {
		t.Fatalf("%s", err)
	}
	t.Logf("%v", ds)
}
func Test_DashboardHTTPService(t *testing.T) {
	var err error
	if testConfig, err = config.LoadConfig(testConfigFile); err != nil {
		t.Fatalf("%s", err)
	}

	testConfig.Datastore.TypeConfig["mapping_file"] = testEssMapFile

	ndhs, err := NewDashboardHTTPService(testConfig, nil)
	if err != nil {
		t.Fatalf("%s", err)
	}

	t.Logf("%v", ndhs)
}
func Test_ElasticsearchDatastore(t *testing.T) {
	var (
		err error
	)

	testConfig, err = config.LoadConfig(testConfigFile)
	if err != nil {
		t.Fatalf("FAILED: %s", err)
	}
	testConfig.Datastore.TypeConfig["mapping_file"] = testEssMapFile

	testEssDs, err = NewElasticsearchDatastore(&testConfig.Datastore, testLogger)
	if err != nil {
		t.Errorf("%s", err)
		t.FailNow()
	}
}