Skip to content

Commit

Permalink
Merge pull request #40 from rralcala/master
Browse files Browse the repository at this point in the history
Fixing bug while creating index name
  • Loading branch information
ringtail authored Oct 11, 2019
2 parents d3bf68b + 6f72222 commit 03a3e2b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func (esSvc *ElasticSearchService) Index(date time.Time, namespace string) strin
if len(namespace) > 0 {
return fmt.Sprintf("%s-%s-%s", esSvc.baseIndex, namespace, dateStr)
}
return fmt.Sprintf("%s-%s", esSvc.baseIndex, date)

return fmt.Sprintf("%s-%s", esSvc.baseIndex, dateStr)
}

func (esSvc *ElasticSearchService) IndexAlias(typeName string) string {
return fmt.Sprintf("%s-%s", esSvc.baseIndex, typeName)
}
Expand Down
24 changes: 24 additions & 0 deletions common/elasticsearch/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,30 @@ func TestCreateElasticSearchServiceWithIngestPipeline(t *testing.T) {

}

func TestIndexName(t *testing.T) {

esURI := "https://foo.com:9200?sniff=false&healthCheck=false"
url, err := url.Parse(esURI)
if err != nil {
t.Fatalf("Error when parsing URL: %s", err.Error())
}
esSvc, err := CreateElasticSearchService(url)
if err != nil {
t.Fatalf("Creating svc: %s", err.Error())
}
indexDate := time.Date(2000, 2, 1, 0, 0, 0, 0, time.UTC)
indexName := esSvc.Index(indexDate, "")
if indexName != "heapster-2000.02.01" {
t.Fatalf("Unexpected index name %s", indexName)
}

indexName = esSvc.Index(indexDate, "application")
if indexName != "heapster-application-2000.02.01" {
t.Fatalf("Unexpected index name %s", indexName)
}

}

func TestCreateElasticSearchServiceSingleDnsEntrypointV5(t *testing.T) {
clusterName := "sandbox"
esURI := fmt.Sprintf("https://foo.com:9200?"+
Expand Down

0 comments on commit 03a3e2b

Please sign in to comment.