-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathGradleTestDevModeActionsWSProjectNameTasks.ts
More file actions
265 lines (218 loc) · 10.9 KB
/
Copy pathGradleTestDevModeActionsWSProjectNameTasks.ts
File metadata and controls
265 lines (218 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
import { expect } from 'chai';
import { InputBox, Workbench,SideBarView, ViewItem, ViewSection,EditorView,DefaultTreeItem, DebugView } from 'vscode-extension-tester';
import * as utils from './utils/testUtils';
import * as constants from './definitions/constants';
import path = require('path');
describe('Devmode action tests for Gradle Project- Project name with space', () => {
let sidebar: SideBarView;
let debugView: DebugView;
let section: ViewSection;
let item: DefaultTreeItem;
let tabs: string[];
before(() => {
sidebar = new SideBarView();
debugView = new DebugView();
});
it('getViewControl works with the correct label', async() => {
const contentPart = sidebar.getContent();
section = await contentPart.getSection('Liberty Dashboard');
console.log("Found Liberty Dashboard....");
expect(section).not.undefined;
}).timeout(25000);
it('Open dasboard shows items - Gradle', async () => {
await utils.delay(85000);
await section.expand();
await utils.delay(6000);
const menu = await section.getVisibleItems();
expect(menu).not.empty;
item = await section.findItem(constants.GRADLE_PROJECT_WSP) as DefaultTreeItem;
expect(item).not.undefined;
}).timeout(300000);
it('Start gradle project from liberty dashboard', async () => {
await utils.launchDashboardAction(item,constants.START_DASHBOARD_ACTION,constants.START_DASHBOARD_MAC_ACTION);
await utils.delay(30000);
const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING);
if(!serverStartStatus)
console.log("Server started message not found in the terminal");
else
{
console.log("Server succuessfully started");
await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION);
const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING);
if(!serverStopStatus){
console.error("Server stopped message not found in the terminal");
}
else
console.log("Server stopped successfully");
expect (serverStopStatus).to.be.true;
}
expect (serverStartStatus).to.be.true;
}).timeout(350000);
it('Run tests for gradle project', async () => {
await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION, constants.START_DASHBOARD_MAC_ACTION);
await utils.delay(30000);
const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING);
console.log("after checkTerminalforServerState");
if(!serverStartStatus)
console.log("Server started message not found in the terminal");
else
{
console.log("Server succuessfully started");
await utils.launchDashboardAction(item,constants.RUNTEST_DASHBOARD_ACTION,constants.RUNTEST_DASHBOARD_MAC_ACTION);
const testStatus = await utils.checkTestStatus(constants.GRADLE_TEST_RUN_STRING);
await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION);
const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING);
if(!serverStopStatus)
console.error("Server stopped message not found in the terminal");
else
console.log("Server stopped successfully");
expect (serverStopStatus).to.be.true;
expect (testStatus).to.be.true;
}
expect (serverStartStatus).to.be.true;
}).timeout(350000);
it('start gradle with options from liberty dashboard', async () => {
const reportPath = path.join(utils.getNewGradleProjectNameWithSpace(),"build", "reports", "tests", "test", "index.html");
const deleteReport = await utils.deleteReports(reportPath);
expect (deleteReport).to.be.true;
await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM);
await utils.setCustomParameter("--hotTests");
await utils.delay(30000);
const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING);
if(!serverStartStatus)
console.log("Server started with params message not found in terminal ");
else
{
console.log("Server succuessfully started");
let checkFile = await utils.checkIfTestReportExists(reportPath);
await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION);
console.log("after dashboard action");
const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING);
if(!serverStopStatus)
console.error("Server stopped message not found in ther terminal");
else
console.log("Server stopped successfully");
expect (serverStopStatus).to.be.true;
expect (checkFile).to.be.true;
}
expect (serverStartStatus).to.be.true;
}).timeout(550000);
it('start gradle with history from liberty dashboard', async () => {
const reportPath = path.join(utils.getNewGradleProjectNameWithSpace(),"build", "reports", "tests", "test", "index.html");
const deleteReport = await utils.deleteReports(reportPath);
expect (deleteReport).to.be.true;
await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM);
const foundCommand = await utils.chooseCmdFromHistory("--hotTests");
console.log("foundcmd:" + foundCommand);
expect (foundCommand).to.be.true;
await utils.delay(30000);
const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING);
if(!serverStartStatus)
console.log("Server started with params message not found in the terminal ");
else
{
console.log("Server succuessfully started");
let checkFile = await utils.checkIfTestReportExists(reportPath);
await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION);
const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING);
if(!serverStopStatus)
console.error("Server stopped message not found in terminal");
else
console.log("Server stopped successfully");
expect (serverStopStatus).to.be.true;
expect (checkFile).to.be.true;
}
expect (serverStartStatus).to.be.true;
}).timeout(350000);
it('attach debugger for gradle with custom parameter event', async () => {
console.log("start attach debugger");
let isServerRunning: Boolean = true;
let attachStatus: Boolean = false;
try {
await utils.launchDashboardAction(item,constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM);
await utils.setCustomParameter("-DdebugPort=7777");
await utils.delay(30000);
isServerRunning = await utils.checkTerminalforServerState(constants.SERVER_START_STRING);
if (!isServerRunning)
console.log("Server started with params message not found in terminal");
else {
console.log("Server succuessfully started");
await utils.launchDashboardAction(item,constants.ATTACH_DEBUGGER_DASHBOARD_ACTION, constants.ATTACH_DEBUGGER_DASHBOARD_MAC_ACTION);
console.log("Attach Debugger action done");
await utils.delay(8000);
const contentPart = debugView.getContent();
//console.log("Get Content");
let mysecarry: Promise<ViewSection[]> = contentPart.getSections();
let mysecmap: IterableIterator<[number, ViewSection]> = (await mysecarry).entries();
for (const [key, value] of (mysecmap)) {
if ((await value.getEnclosingElement().getText()).includes("BREAKPOINTS")) {
//console.log("******** mysecmap getEnclosingElement " + (await value.getEnclosingElement().getText()).valueOf());
console.log("Found Breakpoints");
attachStatus = true;
break;
}
}
await utils.stopLibertyserver();
isServerRunning = !await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING); //negate isServerRunning
if (!isServerRunning)
console.log("Server stopped successfully ");
}
} catch (e) {
console.error("error - ", e)
} finally {
console.log("finally block: is server running - ", isServerRunning);
if (isServerRunning) {
utils.stopLibertyserver();
}
else
console.log("good to close test - Attach Debugger for start with custom parameter(-DdebugPort=7777) event");
}
expect(attachStatus).to.be.true;
}).timeout(550000);
it('start gradle with docker from liberty dashboard', async () => {
if((process.platform === 'darwin' ) || (process.platform === 'win32') || (process.platform == 'linux'))
{
//skip running for platforms , enable them for linux after resolving docker setup in GHA
return true;
}
await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITHDOCKER, constants.START_DASHBOARD_MAC_ACTION_WITHDOCKER);
await utils.delay(60000);
const serverStartStatus = await utils.checkTerminalforServerState(constants.SERVER_START_STRING);
if(!serverStartStatus)
console.log("Server started message not found in the terminal");
else
{
console.log("Server succuessfully started");
await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION);
const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING);
if(!serverStopStatus){
console.error("Server stopped message not found in the terminal");
}
else
console.log("Server stopped successfully");
expect (serverStopStatus).to.be.true;
}
expect (serverStartStatus).to.be.true;
}).timeout(350000);
it('View test report for gradle project', async () => {
if((process.platform === 'darwin' ) || (process.platform === 'win32') || (process.platform == 'linux'))
{
//skip running for platforms , enable once https://github.com/OpenLiberty/liberty-tools-vscode/issues/266 is resolved
return true;
}
await utils.launchDashboardAction(item,constants.GRADLE_TR_DASHABOARD_ACTION, constants.GRADLE_TR_DASHABOARD_MAC_ACTION);
tabs = await new EditorView().getOpenEditorTitles();
// expect (tabs[1]], "Gradle test report not found").to.equal(constants.GRADLE_TEST_REPORT_TITLE);
expect (tabs.indexOf(constants.GRADLE_TEST_REPORT_TITLE)>-1, "Gradle test report not found").to.equal(true);
}).timeout(30000);
// Now, clear the command history of the "command palette" to avoid receiving "recently used" suggestions. This action should be performed at the end of Gradle Project tests.
it('Clear Command Palatte', async () => {
await utils.clearCommandPalette();
}).timeout(100000);
after(() => {
const gradleProjectPath = path.join(__dirname,"..","..","src", "test","resources","gradleproject");
console.log("Current path __dirname: "+ __dirname);
console.log("Removing project from the path: "+ gradleProjectPath);
utils.removeProjectFolder(gradleProjectPath);
});
});