mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: MEGA - Make Eslint Great Again 💅 (#26094)
* Fix lint error in types.ts * Bump eslint and its deps to latest * Add eslintignore and remove not needed eslintrcs * Change webpack configs eslint config * Update package.jsons and removed unused eslintrc files * Chore yarn lint --fix 💅 * Add devenv to eslintignore * Remove eslint disable comments for rules that are not used * Remaining eslint fixes 💅 * Bump grafana/eslint-config 💥 * Modify package.json No need for duplicate checks. * Modify eslintignore to ignore data and dist folders * Revert removing .eslintrc to make sure not to use certain packages * Modify package.json to remove not needed command * Use gitignore for ignoring paths
This commit is contained in:
@@ -3,7 +3,7 @@ import { createClient, createBasicAuthClient } from './modules/client.js';
|
||||
import { createTestOrgIfNotExists, createTestdataDatasourceIfNotExists } from './modules/util.js';
|
||||
|
||||
export let options = {
|
||||
noCookiesReset: true
|
||||
noCookiesReset: true,
|
||||
};
|
||||
|
||||
let endpoint = __ENV.URL || 'http://localhost:3000';
|
||||
@@ -18,35 +18,38 @@ export const setup = () => {
|
||||
orgId: orgId,
|
||||
datasourceId: datasourceId,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default (data) => {
|
||||
group("annotation by tag test", () => {
|
||||
export default data => {
|
||||
group('annotation by tag test', () => {
|
||||
if (__ITER === 0) {
|
||||
group("user authenticates thru ui with username and password", () => {
|
||||
group('user authenticates thru ui with username and password', () => {
|
||||
let res = client.ui.login('admin', 'admin');
|
||||
|
||||
check(res, {
|
||||
'response status is 200': (r) => r.status === 200,
|
||||
'response has cookie \'grafana_session\' with 32 characters': (r) => r.cookies.grafana_session[0].value.length === 32,
|
||||
'response status is 200': r => r.status === 200,
|
||||
"response has cookie 'grafana_session' with 32 characters": r =>
|
||||
r.cookies.grafana_session[0].value.length === 32,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (__ITER !== 0) {
|
||||
group("batch tsdb requests with annotations by tag", () => {
|
||||
group('batch tsdb requests with annotations by tag', () => {
|
||||
const batchCount = 20;
|
||||
const requests = [];
|
||||
const payload = {
|
||||
from: '1547765247624',
|
||||
to: '1547768847624',
|
||||
queries: [{
|
||||
refId: 'A',
|
||||
scenarioId: 'random_walk',
|
||||
intervalMs: 10000,
|
||||
maxDataPoints: 433,
|
||||
datasourceId: data.datasourceId,
|
||||
}]
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
scenarioId: 'random_walk',
|
||||
intervalMs: 10000,
|
||||
maxDataPoints: 433,
|
||||
datasourceId: data.datasourceId,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
requests.push({ method: 'GET', url: '/api/annotations?from=1580825186534&to=1580846786535' });
|
||||
@@ -58,14 +61,14 @@ export default (data) => {
|
||||
let responses = client.batch(requests);
|
||||
for (let n = 0; n < batchCount; n++) {
|
||||
check(responses[n], {
|
||||
'response status is 200': (r) => r.status === 200,
|
||||
'response status is 200': r => r.status === 200,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
sleep(5)
|
||||
}
|
||||
sleep(5);
|
||||
};
|
||||
|
||||
export const teardown = (data) => {}
|
||||
export const teardown = data => {};
|
||||
|
||||
@@ -2,7 +2,7 @@ import { sleep, check, group } from 'k6';
|
||||
import { createBasicAuthClient } from './modules/client.js';
|
||||
|
||||
export let options = {
|
||||
noCookiesReset: true
|
||||
noCookiesReset: true,
|
||||
};
|
||||
|
||||
let endpoint = __ENV.URL || 'http://localhost:10080/grafana';
|
||||
@@ -19,17 +19,17 @@ export const setup = () => {
|
||||
return {
|
||||
datasourceId: res.json().id,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default (data) => {
|
||||
group("auth proxy test", () => {
|
||||
group("batch proxy requests", () => {
|
||||
export default data => {
|
||||
group('auth proxy test', () => {
|
||||
group('batch proxy requests', () => {
|
||||
const d = new Date();
|
||||
const batchCount = 300;
|
||||
const requests = [];
|
||||
const query = encodeURI('topk(5, max(scrape_duration_seconds) by (job))');
|
||||
const start = (d.getTime() / 1000) - 3600;
|
||||
const end = (d.getTime() / 1000);
|
||||
const start = d.getTime() / 1000 - 3600;
|
||||
const end = d.getTime() / 1000;
|
||||
const step = 20;
|
||||
|
||||
requests.push({ method: 'GET', url: '/api/annotations?dashboardId=8&from=1558670300607&to=1558691900607' });
|
||||
@@ -44,13 +44,13 @@ export default (data) => {
|
||||
let responses = client.batch(requests);
|
||||
for (let n = 0; n < batchCount; n++) {
|
||||
check(responses[n], {
|
||||
'response status is 200': (r) => r.status === 200,
|
||||
'response status is 200': r => r.status === 200,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
sleep(5)
|
||||
}
|
||||
sleep(5);
|
||||
};
|
||||
|
||||
export const teardown = (data) => {}
|
||||
export const teardown = data => {};
|
||||
|
||||
@@ -3,11 +3,11 @@ import { createClient, createBasicAuthClient } from './modules/client.js';
|
||||
import { createTestOrgIfNotExists, createTestdataDatasourceIfNotExists } from './modules/util.js';
|
||||
|
||||
export let options = {
|
||||
noCookiesReset: true
|
||||
noCookiesReset: true,
|
||||
};
|
||||
|
||||
let endpoint = __ENV.URL || 'http://localhost:3000';
|
||||
const slowQuery = (__ENV.SLOW_QUERY && __ENV.SLOW_QUERY.length > 0) ? parseInt(__ENV.SLOW_QUERY, 10) : 5;
|
||||
const slowQuery = __ENV.SLOW_QUERY && __ENV.SLOW_QUERY.length > 0 ? parseInt(__ENV.SLOW_QUERY, 10) : 5;
|
||||
const client = createClient(endpoint);
|
||||
|
||||
export const setup = () => {
|
||||
@@ -19,17 +19,18 @@ export const setup = () => {
|
||||
orgId: orgId,
|
||||
datasourceId: datasourceId,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default (data) => {
|
||||
export default data => {
|
||||
group(`user auth token slow test (queries between 1 and ${slowQuery} seconds)`, () => {
|
||||
if (__ITER === 0) {
|
||||
group("user authenticates thru ui with username and password", () => {
|
||||
group('user authenticates thru ui with username and password', () => {
|
||||
let res = client.ui.login('admin', 'admin');
|
||||
|
||||
check(res, {
|
||||
'response status is 200': (r) => r.status === 200,
|
||||
'response has cookie \'grafana_session\' with 32 characters': (r) => r.cookies.grafana_session[0].value.length === 32,
|
||||
'response status is 200': r => r.status === 200,
|
||||
"response has cookie 'grafana_session' with 32 characters": r =>
|
||||
r.cookies.grafana_session[0].value.length === 32,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -41,14 +42,16 @@ export default (data) => {
|
||||
const payload = {
|
||||
from: '1547765247624',
|
||||
to: '1547768847624',
|
||||
queries: [{
|
||||
refId: 'A',
|
||||
scenarioId: 'slow_query',
|
||||
stringInput: `${Math.floor(Math.random() * slowQuery) + 1}s`,
|
||||
intervalMs: 10000,
|
||||
maxDataPoints: 433,
|
||||
datasourceId: data.datasourceId,
|
||||
}]
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
scenarioId: 'slow_query',
|
||||
stringInput: `${Math.floor(Math.random() * slowQuery) + 1}s`,
|
||||
intervalMs: 10000,
|
||||
maxDataPoints: 433,
|
||||
datasourceId: data.datasourceId,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
requests.push({ method: 'GET', url: '/api/annotations?dashboardId=2074&from=1548078832772&to=1548082432772' });
|
||||
@@ -60,14 +63,14 @@ export default (data) => {
|
||||
let responses = client.batch(requests);
|
||||
for (let n = 0; n < batchCount; n++) {
|
||||
check(responses[n], {
|
||||
'response status is 200': (r) => r.status === 200,
|
||||
'response status is 200': r => r.status === 200,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
sleep(5)
|
||||
}
|
||||
sleep(5);
|
||||
};
|
||||
|
||||
export const teardown = (data) => {}
|
||||
export const teardown = data => {};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createClient, createBasicAuthClient } from './modules/client.js';
|
||||
import { createTestOrgIfNotExists, createTestdataDatasourceIfNotExists } from './modules/util.js';
|
||||
|
||||
export let options = {
|
||||
noCookiesReset: true
|
||||
noCookiesReset: true,
|
||||
};
|
||||
|
||||
let endpoint = __ENV.URL || 'http://localhost:3000';
|
||||
@@ -18,35 +18,38 @@ export const setup = () => {
|
||||
orgId: orgId,
|
||||
datasourceId: datasourceId,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default (data) => {
|
||||
group("user auth token test", () => {
|
||||
export default data => {
|
||||
group('user auth token test', () => {
|
||||
if (__ITER === 0) {
|
||||
group("user authenticates thru ui with username and password", () => {
|
||||
group('user authenticates thru ui with username and password', () => {
|
||||
let res = client.ui.login('admin', 'admin');
|
||||
|
||||
check(res, {
|
||||
'response status is 200': (r) => r.status === 200,
|
||||
'response has cookie \'grafana_session\' with 32 characters': (r) => r.cookies.grafana_session[0].value.length === 32,
|
||||
'response status is 200': r => r.status === 200,
|
||||
"response has cookie 'grafana_session' with 32 characters": r =>
|
||||
r.cookies.grafana_session[0].value.length === 32,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (__ITER !== 0) {
|
||||
group("batch tsdb requests", () => {
|
||||
group('batch tsdb requests', () => {
|
||||
const batchCount = 20;
|
||||
const requests = [];
|
||||
const payload = {
|
||||
from: '1547765247624',
|
||||
to: '1547768847624',
|
||||
queries: [{
|
||||
refId: 'A',
|
||||
scenarioId: 'random_walk',
|
||||
intervalMs: 10000,
|
||||
maxDataPoints: 433,
|
||||
datasourceId: data.datasourceId,
|
||||
}]
|
||||
queries: [
|
||||
{
|
||||
refId: 'A',
|
||||
scenarioId: 'random_walk',
|
||||
intervalMs: 10000,
|
||||
maxDataPoints: 433,
|
||||
datasourceId: data.datasourceId,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
requests.push({ method: 'GET', url: '/api/annotations?dashboardId=2074&from=1548078832772&to=1548082432772' });
|
||||
@@ -58,14 +61,14 @@ export default (data) => {
|
||||
let responses = client.batch(requests);
|
||||
for (let n = 0; n < batchCount; n++) {
|
||||
check(responses[n], {
|
||||
'response status is 200': (r) => r.status === 200,
|
||||
'response status is 200': r => r.status === 200,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
sleep(5)
|
||||
}
|
||||
sleep(5);
|
||||
};
|
||||
|
||||
export const teardown = (data) => {}
|
||||
export const teardown = data => {};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import http from "k6/http";
|
||||
import http from 'k6/http';
|
||||
import encoding from 'k6/encoding';
|
||||
|
||||
export const UIEndpoint = class UIEndpoint {
|
||||
@@ -10,7 +10,7 @@ export const UIEndpoint = class UIEndpoint {
|
||||
const payload = { user: username, password: pwd };
|
||||
return this.httpClient.formPost('/login', payload);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const DatasourcesEndpoint = class DatasourcesEndpoint {
|
||||
constructor(httpClient) {
|
||||
@@ -32,7 +32,7 @@ export const DatasourcesEndpoint = class DatasourcesEndpoint {
|
||||
delete(id) {
|
||||
return this.httpClient.delete(`/datasources/${id}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const OrganizationsEndpoint = class OrganizationsEndpoint {
|
||||
constructor(httpClient) {
|
||||
@@ -57,7 +57,7 @@ export const OrganizationsEndpoint = class OrganizationsEndpoint {
|
||||
delete(id) {
|
||||
return this.httpClient.delete(`/orgs/${id}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const GrafanaClient = class GrafanaClient {
|
||||
constructor(httpClient) {
|
||||
@@ -79,10 +79,10 @@ export const GrafanaClient = class GrafanaClient {
|
||||
onBeforeRequest(params) {
|
||||
if (this.orgId && this.orgId > 0) {
|
||||
params = params.headers || {};
|
||||
params.headers["X-Grafana-Org-Id"] = this.orgId;
|
||||
params.headers['X-Grafana-Org-Id'] = this.orgId;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const BaseClient = class BaseClient {
|
||||
constructor(url, subUrl) {
|
||||
@@ -99,14 +99,12 @@ export const BaseClient = class BaseClient {
|
||||
}
|
||||
|
||||
withUrl(subUrl) {
|
||||
let c = new BaseClient(this.url, subUrl);
|
||||
let c = new BaseClient(this.url, subUrl);
|
||||
c.onBeforeRequest = this.onBeforeRequest;
|
||||
return c;
|
||||
}
|
||||
|
||||
beforeRequest(params) {
|
||||
|
||||
}
|
||||
beforeRequest(params) {}
|
||||
|
||||
get(url, params) {
|
||||
params = params || {};
|
||||
@@ -156,7 +154,7 @@ export const BaseClient = class BaseClient {
|
||||
|
||||
return http.batch(requests);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export class BasicAuthClient extends BaseClient {
|
||||
constructor(url, subUrl, username, password) {
|
||||
@@ -166,7 +164,7 @@ export class BasicAuthClient extends BaseClient {
|
||||
}
|
||||
|
||||
withUrl(subUrl) {
|
||||
let c = new BasicAuthClient(this.url, subUrl, this.username, this.password);
|
||||
let c = new BasicAuthClient(this.url, subUrl, this.username, this.password);
|
||||
c.onBeforeRequest = this.onBeforeRequest;
|
||||
return c;
|
||||
}
|
||||
@@ -179,10 +177,10 @@ export class BasicAuthClient extends BaseClient {
|
||||
}
|
||||
}
|
||||
|
||||
export const createClient = (url) => {
|
||||
export const createClient = url => {
|
||||
return new GrafanaClient(new BaseClient(url, ''));
|
||||
}
|
||||
};
|
||||
|
||||
export const createBasicAuthClient = (url, username, password) => {
|
||||
return new GrafanaClient(new BasicAuthClient(url, '', username, password));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const createTestOrgIfNotExists = (client) => {
|
||||
export const createTestOrgIfNotExists = client => {
|
||||
let orgId = 0;
|
||||
let res = client.orgs.getByName('k6');
|
||||
if (res.status === 404) {
|
||||
@@ -13,9 +13,9 @@ export const createTestOrgIfNotExists = (client) => {
|
||||
|
||||
client.withOrgId(orgId);
|
||||
return orgId;
|
||||
}
|
||||
};
|
||||
|
||||
export const createTestdataDatasourceIfNotExists = (client) => {
|
||||
export const createTestdataDatasourceIfNotExists = client => {
|
||||
const payload = {
|
||||
access: 'proxy',
|
||||
isDefault: false,
|
||||
@@ -32,4 +32,4 @@ export const createTestdataDatasourceIfNotExists = (client) => {
|
||||
}
|
||||
|
||||
return res.json().id;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user