Plumb through log analytics values (#274)
* plumb through log analytics values * add option to specify a log analytics file as well * use secret for log analytics
This commit is contained in:
committed by
Robbie Zhang
parent
28daffa96f
commit
ef6ae9ecf4
38
providers/azure/client/aci/analytics_test.go
Normal file
38
providers/azure/client/aci/analytics_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package aci
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLogAnalyticsFileParsingSuccess(t *testing.T) {
|
||||
diagnostics, err := NewContainerGroupDiagnosticsFromFile("../../../../loganalytics.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if diagnostics == nil || diagnostics.LogAnalytics == nil {
|
||||
t.Fatalf("Unexpected nil diagnostics. Log Analytics file not parsed correctly")
|
||||
}
|
||||
|
||||
if diagnostics.LogAnalytics.WorkspaceID == "" || diagnostics.LogAnalytics.WorkspaceKey == "" {
|
||||
t.Fatalf("Unexpected empty analytics authentication credentials. Log Analytics file not parsed correctly")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLogAnalyticsFileParsingFailure(t *testing.T) {
|
||||
tempFile, err := ioutil.TempFile("", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = NewContainerGroupDiagnosticsFromFile(tempFile.Name())
|
||||
|
||||
// Cleaup
|
||||
tempFile.Close()
|
||||
os.Remove(tempFile.Name())
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("Expected parsing an empty Log Analytics auth file to fail, but there were no errors")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user