Toolkit: Remove deprecated searchTestData (#67134)

This commit is contained in:
Esteban Beltran 2023-04-25 11:52:59 +02:00 committed by GitHub
parent 714d2a4154
commit 0d0c6401e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 145 deletions

View File

@ -896,20 +896,6 @@ exports[`better eslint`] = {
"packages/grafana-toolkit/src/cli/tasks/plugin/bundle.managed.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-toolkit/src/cli/tasks/searchTestDataSetup.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"]
],
"packages/grafana-toolkit/src/cli/tasks/task.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],

View File

@ -9,7 +9,6 @@ import { pluginSignTask } from './tasks/plugin.sign';
import { pluginUpdateTask } from './tasks/plugin.update';
import { getToolkitVersion, githubPublishTask } from './tasks/plugin.utils';
import { bundleManagedTask } from './tasks/plugin/bundle.managed';
import { searchTestDataSetupTask } from './tasks/searchTestDataSetup';
import { templateTask } from './tasks/template';
import { toolkitBuildTask } from './tasks/toolkit.build';
import { execTask } from './utils/execTask';
@ -65,19 +64,6 @@ export const run = (includeInternalScripts = false) => {
);
await execTask(toolkitBuildTask)({});
});
program
.command('searchTestData')
.option('-c, --count <number_of_dashboards>', 'Specify number of dashboards')
.description('[deprecated] Setup test data for search')
.action(async (cmd) => {
console.log(
chalk.yellow.bold(
`⚠️ This command is deprecated and will be removed in v10. No further support will be provided. ⚠️`
)
);
await execTask(searchTestDataSetupTask)({ count: cmd.count });
});
}
program.option('-v, --version', 'Toolkit version').action(async () => {

View File

@ -1,117 +0,0 @@
import axios from 'axios';
import { Task, TaskRunner } from './task';
interface SearchTestDataSetupOptions {
count: number;
}
const client = axios.create({
baseURL: 'http://localhost:3000/api',
auth: {
username: 'admin',
password: 'admin2',
},
});
export async function getUser(user: any): Promise<any> {
console.log('Creating user ' + user.name);
const search = await client.get('/users/search', {
params: { query: user.login },
});
if (search.data.totalCount === 1) {
user.id = search.data.users[0].id;
return user;
}
const rsp = await client.post('/admin/users', user);
user.id = rsp.data.id;
return user;
}
export async function getTeam(team: any): Promise<any> {
// delete if exists
const teams = await client.get('/teams/search');
for (const existing of teams.data.teams) {
if (existing.name === team.name) {
console.log('Team exists, deleting');
await client.delete('/teams/' + existing.id);
}
}
console.log('Creating team ' + team.name);
const teamRsp = await client.post(`/teams`, team);
team.id = teamRsp.data.teamId;
return team;
}
export async function addToTeam(team: any, user: any): Promise<any> {
console.log(`Adding user ${user.name} to team ${team.name}`);
await client.post(`/teams/${team.id}/members`, { userId: user.id });
}
export async function setDashboardAcl(dashboardId: any, aclList: any) {
console.log('Setting Dashboard ACL ' + dashboardId);
await client.post(`/dashboards/id/${dashboardId}/permissions`, { items: aclList });
}
const searchTestDataSetupRunner: TaskRunner<SearchTestDataSetupOptions> = async ({ count }) => {
const user1 = await getUser({
name: 'searchTestUser1',
email: 'searchTestUser@team.com',
login: 'searchTestUser1',
password: '12345',
});
const team1 = await getTeam({ name: 'searchTestTeam1', email: 'searchtestdata@team.com' });
addToTeam(team1, user1);
// create or update folder
const folder: any = {
uid: 'search-test-data',
title: 'Search test data folder',
version: 1,
};
try {
await client.delete(`/folders/${folder.uid}`);
} catch (err) {}
console.log('Creating folder');
const rsp = await client.post(`/folders`, folder);
folder.id = rsp.data.id;
folder.url = rsp.data.url;
await setDashboardAcl(folder.id, []);
console.log('Creating dashboards');
const dashboards: any = [];
for (let i = 0; i < count; i++) {
const dashboard: any = {
uid: 'search-test-dash-' + i.toString().padStart(5, '0'),
title: 'Search test dash ' + i.toString().padStart(5, '0'),
};
const rsp = await client.post(`/dashboards/db`, {
dashboard: dashboard,
folderId: folder.id,
overwrite: true,
});
dashboard.id = rsp.data.id;
dashboard.url = rsp.data.url;
console.log('Created dashboard ' + dashboard.title);
dashboards.push(dashboard);
await setDashboardAcl(dashboard.id, [{ userId: 0, teamId: team1.id, permission: 4 }]);
}
};
export const searchTestDataSetupTask = new Task<SearchTestDataSetupOptions>(
'Search test data setup',
searchTestDataSetupRunner
);