|
|
|
|
@ -102,8 +102,8 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
datasourceRequestMock.mockImplementation(() => Promise.resolve(response)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of subscriptions', () => { |
|
|
|
|
return ctx.ds.metricFindQuery('subscriptions()').then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
it('should return a list of subscriptions', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery('subscriptions()'); |
|
|
|
|
expect(results.length).toBe(2); |
|
|
|
|
expect(results[0].text).toBe('Primary'); |
|
|
|
|
expect(results[0].value).toBe('sub1'); |
|
|
|
|
@ -111,7 +111,6 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
expect(results[1].value).toBe('sub2'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('with a resource groups query', () => { |
|
|
|
|
const response = { |
|
|
|
|
@ -126,8 +125,8 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
datasourceRequestMock.mockImplementation(() => Promise.resolve(response)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of resource groups', () => { |
|
|
|
|
return ctx.ds.metricFindQuery('ResourceGroups()').then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
it('should return a list of resource groups', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery('ResourceGroups()'); |
|
|
|
|
expect(results.length).toBe(2); |
|
|
|
|
expect(results[0].text).toBe('grp1'); |
|
|
|
|
expect(results[0].value).toBe('grp1'); |
|
|
|
|
@ -135,7 +134,6 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
expect(results[1].value).toBe('grp2'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('with a resource groups query that specifies a subscription id', () => { |
|
|
|
|
const response = { |
|
|
|
|
@ -153,10 +151,8 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of resource groups', () => { |
|
|
|
|
return ctx.ds |
|
|
|
|
.metricFindQuery('ResourceGroups(11112222-eeee-4949-9b2d-9106972f9123)') |
|
|
|
|
.then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
it('should return a list of resource groups', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery('ResourceGroups(11112222-eeee-4949-9b2d-9106972f9123)'); |
|
|
|
|
expect(results.length).toBe(2); |
|
|
|
|
expect(results[0].text).toBe('grp1'); |
|
|
|
|
expect(results[0].value).toBe('grp1'); |
|
|
|
|
@ -164,7 +160,6 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
expect(results[1].value).toBe('grp2'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('with namespaces query', () => { |
|
|
|
|
const response = { |
|
|
|
|
@ -189,16 +184,13 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of namespaces', () => { |
|
|
|
|
return ctx.ds |
|
|
|
|
.metricFindQuery('Namespaces(nodesapp)') |
|
|
|
|
.then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
it('should return a list of namespaces', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery('Namespaces(nodesapp)'); |
|
|
|
|
expect(results.length).toEqual(1); |
|
|
|
|
expect(results[0].text).toEqual('Microsoft.Network/networkInterfaces'); |
|
|
|
|
expect(results[0].value).toEqual('Microsoft.Network/networkInterfaces'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('with namespaces query that specifies a subscription id', () => { |
|
|
|
|
const response = { |
|
|
|
|
@ -223,16 +215,13 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of namespaces', () => { |
|
|
|
|
return ctx.ds |
|
|
|
|
.metricFindQuery('namespaces(11112222-eeee-4949-9b2d-9106972f9123, nodesapp)') |
|
|
|
|
.then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
it('should return a list of namespaces', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery('namespaces(11112222-eeee-4949-9b2d-9106972f9123, nodesapp)'); |
|
|
|
|
expect(results.length).toEqual(1); |
|
|
|
|
expect(results[0].text).toEqual('Microsoft.Network/networkInterfaces'); |
|
|
|
|
expect(results[0].value).toEqual('Microsoft.Network/networkInterfaces'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('with resource names query', () => { |
|
|
|
|
const response = { |
|
|
|
|
@ -261,16 +250,13 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of resource names', () => { |
|
|
|
|
return ctx.ds |
|
|
|
|
.metricFindQuery('resourceNames(nodeapp, microsoft.insights/components )') |
|
|
|
|
.then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
it('should return a list of resource names', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery('resourceNames(nodeapp, microsoft.insights/components )'); |
|
|
|
|
expect(results.length).toEqual(1); |
|
|
|
|
expect(results[0].text).toEqual('nodeapp'); |
|
|
|
|
expect(results[0].value).toEqual('nodeapp'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('with resource names query and that specifies a subscription id', () => { |
|
|
|
|
const response = { |
|
|
|
|
@ -347,10 +333,10 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of metric names', () => { |
|
|
|
|
return ctx.ds |
|
|
|
|
.metricFindQuery('Metricnames(nodeapp, microsoft.insights/components, rn, default)') |
|
|
|
|
.then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
it('should return a list of metric names', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery( |
|
|
|
|
'Metricnames(nodeapp, microsoft.insights/components, rn, default)' |
|
|
|
|
); |
|
|
|
|
expect(results.length).toEqual(2); |
|
|
|
|
expect(results[0].text).toEqual('Percentage CPU'); |
|
|
|
|
expect(results[0].value).toEqual('Percentage CPU'); |
|
|
|
|
@ -359,7 +345,6 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
expect(results[1].value).toEqual('UsedCapacity'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('with metric names query and specifies a subscription id', () => { |
|
|
|
|
const response = { |
|
|
|
|
@ -396,12 +381,10 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of metric names', () => { |
|
|
|
|
return ctx.ds |
|
|
|
|
.metricFindQuery( |
|
|
|
|
it('should return a list of metric names', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery( |
|
|
|
|
'Metricnames(11112222-eeee-4949-9b2d-9106972f9123, nodeapp, microsoft.insights/components, rn, default)' |
|
|
|
|
) |
|
|
|
|
.then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
); |
|
|
|
|
expect(results.length).toEqual(2); |
|
|
|
|
expect(results[0].text).toEqual('Percentage CPU'); |
|
|
|
|
expect(results[0].value).toEqual('Percentage CPU'); |
|
|
|
|
@ -410,7 +393,6 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
expect(results[1].value).toEqual('UsedCapacity'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('with metric namespace query', () => { |
|
|
|
|
const response = { |
|
|
|
|
@ -446,10 +428,8 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of metric names', () => { |
|
|
|
|
return ctx.ds |
|
|
|
|
.metricFindQuery('Metricnamespace(nodeapp, Microsoft.Compute/virtualMachines, rn)') |
|
|
|
|
.then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
it('should return a list of metric names', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery('Metricnamespace(nodeapp, Microsoft.Compute/virtualMachines, rn)'); |
|
|
|
|
expect(results.length).toEqual(2); |
|
|
|
|
expect(results[0].text).toEqual('Microsoft.Compute-virtualMachines'); |
|
|
|
|
expect(results[0].value).toEqual('Microsoft.Compute/virtualMachines'); |
|
|
|
|
@ -458,7 +438,6 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
expect(results[1].value).toEqual('Telegraf/mem'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('with metric namespace query and specifies a subscription id', () => { |
|
|
|
|
const response = { |
|
|
|
|
@ -494,12 +473,10 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should return a list of metric namespaces', () => { |
|
|
|
|
return ctx.ds |
|
|
|
|
.metricFindQuery( |
|
|
|
|
it('should return a list of metric namespaces', async () => { |
|
|
|
|
const results = await ctx.ds.metricFindQuery( |
|
|
|
|
'Metricnamespace(11112222-eeee-4949-9b2d-9106972f9123, nodeapp, Microsoft.Compute/virtualMachines, rn)' |
|
|
|
|
) |
|
|
|
|
.then((results: Array<{ text: string; value: string }>) => { |
|
|
|
|
); |
|
|
|
|
expect(results.length).toEqual(2); |
|
|
|
|
expect(results[0].text).toEqual('Microsoft.Compute-virtualMachines'); |
|
|
|
|
expect(results[0].value).toEqual('Microsoft.Compute/virtualMachines'); |
|
|
|
|
@ -509,7 +486,6 @@ describe('AzureMonitorDatasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('When performing getSubscriptions', () => { |
|
|
|
|
const response = { |
|
|
|
|
|