-
Notifications
You must be signed in to change notification settings - Fork 188
/
MidScaleGuiTest.java
266 lines (213 loc) · 10.4 KB
/
MidScaleGuiTest.java
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
265
266
/*
* Copyright (c) 2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.gui;
import com.evolveum.midpoint.gui.api.component.MainObjectListPanel;
import com.evolveum.midpoint.tools.testng.PerformanceTestMethodMixin;
import com.evolveum.midpoint.web.page.admin.configuration.PageSystemConfiguration;
import com.evolveum.midpoint.web.page.admin.server.PageTasks;
import org.apache.wicket.Page;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.javasimon.Split;
import org.javasimon.Stopwatch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.evolveum.midpoint.gui.test.TestMidPointSpringApplication;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.repo.sql.testing.TestQueryListener;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.statistics.OperationsPerformanceInformationUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.statistics.OperationsPerformanceMonitor;
import com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest;
import com.evolveum.midpoint.web.page.admin.home.PageDashboardInfo;
import com.evolveum.midpoint.web.page.admin.users.PageOrgTree;
import com.evolveum.midpoint.web.page.admin.users.PageUser;
import com.evolveum.midpoint.web.page.admin.users.PageUsers;
import com.evolveum.midpoint.web.page.self.PageAssignmentShoppingCart;
import com.evolveum.midpoint.web.page.self.PageSelfCredentials;
import com.evolveum.midpoint.web.page.self.PageSelfDashboard;
import com.evolveum.midpoint.web.page.self.PageUserSelfProfile;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import java.io.File;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@ActiveProfiles("test")
@SpringBootTest(classes = TestMidPointSpringApplication.class)
public class MidScaleGuiTest extends AbstractInitializedGuiIntegrationTest implements PerformanceTestMethodMixin {
private static final String TEST_DIR = "./src/test/resources/midScale";
private static final File FILE_ORG_STRUCT = new File(TEST_DIR, "org-struct.xml");
private static final File FILE_USERS = new File(TEST_DIR, "users.xml");
private static final int REPETITION_COUNT = 10;
@Autowired TestQueryListener queryListener;
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
importObjectsFromFileNotRaw(FILE_ORG_STRUCT, initTask, initResult);
initResult.computeStatusIfUnknown();
if (!initResult.isSuccess()) {
System.out.println("init result:\n" + initResult);
}
importObjectsFromFileNotRaw(FILE_USERS, initTask, initResult);
modifyObjectReplaceProperty(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(),
ItemPath.create(SystemConfigurationType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_ENABLE_EXPERIMENTAL_FEATURES),
initTask, initResult, true);
}
@BeforeMethod
public void resetQueryListener() {
queryListener.clear();
}
@Test
public void test010PageSelfDashboard() {
displayTestTitle(getTestName());
runTestFor(PageSelfDashboard.class, "selfDashboard", "Home");
}
@Test
public void test020PageSelfProfile() {
displayTestTitle(getTestName());
runTestFor(PageUserSelfProfile.class, "selfProfile", "Profile");
}
@Test
public void test030PageSelfCredentials() {
displayTestTitle(getTestName());
runTestFor(PageSelfCredentials.class, "rcredentials", "Credentials");
}
@Test
public void test040PageRequestRole() {
displayTestTitle(getTestName());
runTestFor(PageAssignmentShoppingCart.class, "requestRole", "Request a role");
}
@Test
public void test110PageDashboard() {
displayTestTitle(getTestName());
runTestFor(PageDashboardInfo.class, "dashboard", "Info Dashboard");
}
private void runTestFor(Class pageToRender, String stopwatchName, String stopwatchDescription) {
runTestFor(pageToRender, null, stopwatchName, stopwatchDescription);
}
private void runTestFor(Class pageToRender, PageParameters params, String stopwatchName, String stopwatchDescription) {
Stopwatch stopwatch = stopwatch(stopwatchName, stopwatchDescription);
for (int i = 0; i < REPETITION_COUNT; i++) {
try (Split ignored = stopwatch.start()) {
queryListener.start();
tester.startPage(pageToRender);
}
}
queryListener.dumpAndStop();
tester.assertRenderedPage(pageToRender);
OperationsPerformanceInformationType performanceInformation =
OperationsPerformanceInformationUtil.toOperationsPerformanceInformationType(
OperationsPerformanceMonitor.INSTANCE.getGlobalPerformanceInformation());
displayValue("Operation performance (by name)",
OperationsPerformanceInformationUtil.format(performanceInformation));
}
@Test
public void test210listUsers() {
logger.info(getTestName());
runTestFor(PageUsers.class, "listUsers", "List users");
}
@Test
public void test220newUser() {
logger.info(getTestName());
runTestFor(PageUser.class, "newUser", "New user");
}
@Test
public void test230editUser() {
logger.info(getTestName());
for (int i = 0; i < REPETITION_COUNT; i++) {
tester.startPage(PageUsers.class);
String idTable = "mainForm:table";
tester.assertComponent(idTable, MainObjectListPanel.class);
tester.debugComponentTrees(":rows:.*:cells:3:cell:link");
String id = idTable + ":mainForm:table:box:tableContainer:table:body:rows:3:cells:3:cell:link";
Stopwatch stopwatch = stopwatch("editUser", "Edit User");
try (Split ignored = stopwatch.start()) {
queryListener.start();
tester.clickLink(id);
}
}
queryListener.dumpAndStop();
tester.assertRenderedPage(PageUser.class);
OperationsPerformanceInformationType performanceInformation =
OperationsPerformanceInformationUtil.toOperationsPerformanceInformationType(
OperationsPerformanceMonitor.INSTANCE.getGlobalPerformanceInformation());
displayValue("Operation performance (by name)",
OperationsPerformanceInformationUtil.format(performanceInformation));
}
@Test
public void test231editUserTabProjections() {
logger.info(getTestName());
for (int i = 0; i < REPETITION_COUNT; i++) {
tester.startPage(PageUsers.class);
String idTable = "mainForm:table";
tester.assertComponent(idTable, MainObjectListPanel.class);
tester.debugComponentTrees(":rows:.*:cells:3:cell:link");
String id = idTable + ":mainForm:table:box:tableContainer:table:body:rows:3:cells:3:cell:link";
tester.clickLink(id);
Stopwatch stopwatch = stopwatch("showProjections", "User's projection tab");
try (Split ignored = stopwatch.start()) {
clickOnTab(1, PageUser.class);
queryListener.start();
}
}
queryListener.dumpAndStop();
tester.assertRenderedPage(PageUser.class);
OperationsPerformanceInformationType performanceInformation =
OperationsPerformanceInformationUtil.toOperationsPerformanceInformationType(
OperationsPerformanceMonitor.INSTANCE.getGlobalPerformanceInformation());
displayValue("Operation performance (by name)",
OperationsPerformanceInformationUtil.format(performanceInformation));
}
@Test
public void test232editUserTabAssignments() {
logger.info(getTestName());
for (int i = 0; i < REPETITION_COUNT; i++) {
tester.startPage(PageUsers.class);
String idTable = "mainForm:table";
tester.assertComponent(idTable, MainObjectListPanel.class);
tester.debugComponentTrees(":rows:.*:cells:3:cell:link");
String id = idTable + ":mainForm:table:box:tableContainer:table:body:rows:3:cells:3:cell:link";
tester.clickLink(id);
Stopwatch stopwatch = stopwatch("showAssignments", "User's assignmentTab");
try (Split ignored = stopwatch.start()) {
queryListener.start();
clickOnTab(2, PageUser.class);
}
}
queryListener.dumpAndStop();
tester.assertRenderedPage(PageUser.class);
OperationsPerformanceInformationType performanceInformation =
OperationsPerformanceInformationUtil.toOperationsPerformanceInformationType(
OperationsPerformanceMonitor.INSTANCE.getGlobalPerformanceInformation());
displayValue("Operation performance (by name)",
OperationsPerformanceInformationUtil.format(performanceInformation));
}
@Test
public void test310orgTree() throws Exception {
logger.info(getTestName());
runTestFor(PageOrgTree.class, "orgTree", "Organization tree");
}
@Test
public void test410allTasks() {
logger.info(getTestName());
runTestFor(PageTasks.class, "tasks", "All tasks");
}
@Test
public void test510systemConfigurationAdminGuiConfig() {
logger.info(getTestName());
PageParameters params = new PageParameters();
params.add(PageSystemConfiguration.SELECTED_TAB_INDEX, PageSystemConfiguration.CONFIGURATION_TAB_ADMIN_GUI);
runTestFor(PageSystemConfiguration.class, params,"adminGuiConfig", "Admin Gui Config");
}
private void clickOnTab(int order, Class<? extends Page> expectedPage) {
tester.assertRenderedPage(expectedPage);
String tabPath = "mainPanel:mainForm:tabPanel:tabs-container:tabs:" + order + ":link";
tester.clickLink(tabPath);
}
}