Add timeout option to datasource config (#31871)

This commit is contained in:
Arseny Smalyuk
2021-04-07 17:46:19 +03:00
committed by GitHub
parent 7a68852aa7
commit 8e70d5d181
4 changed files with 61 additions and 15 deletions

View File

@ -214,6 +214,25 @@ func TestDataSource_GetHttpTransport(t *testing.T) {
assert.Equal(t, "Ok", bodyStr)
})
t.Run("Should use request timeout if configured in JsonData", func(t *testing.T) {
clearDSProxyCache(t)
json := simplejson.NewFromAny(map[string]interface{}{
"timeout": 19,
})
ds := DataSource{
Id: 1,
Url: "http://k8s:8001",
Type: "Kubernetes",
JsonData: json,
}
client, err := ds.GetHttpClient()
require.NoError(t, err)
assert.Equal(t, 19*time.Second, client.Timeout)
})
t.Run("Should not include SigV4 middleware if not configured in JsonData", func(t *testing.T) {
clearDSProxyCache(t)