Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build tags for cloud tests #16937

Merged
merged 14 commits into from
Mar 17, 2020
Prev Previous commit
Next Next commit
Add tags for azure tests in filebeat
  • Loading branch information
jsoriano committed Mar 10, 2020
commit a4f9d21ca4c09d6417c5698ec752b65d4080ad2f
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// you may not use this file except in compliance with the Elastic License.

// +build integration
// +build azure

package azureeventhub

Expand All @@ -23,26 +24,20 @@ import (
)

var (

// setup the input config
azureConfig = common.MustNewConfigFrom(common.MapStr{
"storage_account_key": os.Getenv("STORAGE_ACCOUNT_NAME"),
"storage_account": os.Getenv("STORAGE_ACCOUNT_KEY"),
"storage_account_key": lookupEnv("STORAGE_ACCOUNT_NAME"),
"storage_account": lookupEnv("STORAGE_ACCOUNT_KEY"),
"storage_account_container": ephContainerName,
"connection_string": os.Getenv("EVENTHUB_CONNECTION_STRING"),
"consumer_group": os.Getenv("EVENTHUB_CONSUMERGROUP"),
"eventhub": os.Getenv("EVENTHUB_NAME"),
"connection_string": lookupEnv("EVENTHUB_CONNECTION_STRING"),
"consumer_group": lookupEnv("EVENTHUB_CONSUMERGROUP"),
"eventhub": lookupEnv("EVENTHUB_NAME"),
})

message = "{\"records\":[{\"some_field\":\"this is some message\",\"time\":\"2019-12-17T13:43:44.4946995Z\"}"
)

func TestInput(t *testing.T) {
if os.Getenv("EVENTHUB_NAME") == "" || os.Getenv("EVENTHUB_CONNECTION_STRING") == "" {
t.Skip("EVENTHUB_NAME or/and EVENTHUB_CONSUMERGROUP are not set in environment.")
}
err := addEventToHub(os.Getenv("EVENTHUB_CONNECTION_STRING"))

err := addEventToHub(lookupEnv("EVENTHUB_CONNECTION_STRING"))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -99,6 +94,14 @@ func TestInput(t *testing.T) {
}
}

func lookupEnv(t *testing.T, varName string) string {
value, ok := os.LookupEnv(varName)
if !ok {
t.Fatalf("Environment variable %s is not set", varName)
}
return value
}

func addEventToHub(connStr string) error {
hub, err := eventhub.NewHubFromConnectionString(connStr)
if err != nil {
Expand Down