1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.hal.testsuite.test.configuration.modcluster;
17
18 import org.jboss.arquillian.core.api.annotation.Inject;
19 import org.jboss.arquillian.graphene.page.Page;
20 import org.jboss.hal.testsuite.Console;
21 import org.jboss.hal.testsuite.CrudOperations;
22 import org.jboss.hal.testsuite.Random;
23 import org.jboss.hal.testsuite.container.WildFlyContainer;
24 import org.jboss.hal.testsuite.fragment.FormFragment;
25 import org.jboss.hal.testsuite.fragment.TableFragment;
26 import org.jboss.hal.testsuite.page.configuration.ModclusterPage;
27 import org.jboss.hal.testsuite.test.Manatoko;
28 import org.junit.jupiter.api.BeforeAll;
29 import org.junit.jupiter.api.BeforeEach;
30 import org.junit.jupiter.api.Test;
31 import org.testcontainers.junit.jupiter.Container;
32 import org.testcontainers.junit.jupiter.Testcontainers;
33 import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
34 import org.wildfly.extras.creaper.core.online.operations.Batch;
35 import org.wildfly.extras.creaper.core.online.operations.Operations;
36 import org.wildfly.extras.creaper.core.online.operations.Values;
37
38 import static org.jboss.hal.dmr.ModelDescriptionConstants.CLASS;
39 import static org.jboss.hal.dmr.ModelDescriptionConstants.DEFAULT;
40 import static org.jboss.hal.dmr.ModelDescriptionConstants.LISTENER;
41 import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
42 import static org.jboss.hal.testsuite.container.WildFlyConfiguration.HA;
43 import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.CLASS_NAME;
44 import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.CUSTOM_LOAD_METRIC_CREATE;
45 import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.CUSTOM_LOAD_METRIC_DELETE;
46 import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.CUSTOM_LOAD_METRIC_UPDATE;
47 import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.PROXY_UPDATE;
48 import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.WEIGHT;
49 import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.customLoadMetricAddress;
50 import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.loadProviderDynamicAddress;
51 import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.proxyAddress;
52
53 @Manatoko
54 @Testcontainers
55 class CustomLoadMetricTest {
56
57 @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(HA);
58
59 @BeforeAll
60 static void setupModel() throws Exception {
61 OnlineManagementClient client = wildFly.managementClient();
62 Operations operations = new Operations(client);
63 Batch proxyAdd = new Batch();
64 proxyAdd.add(proxyAddress(PROXY_UPDATE), Values.of(LISTENER, DEFAULT));
65 proxyAdd.add(loadProviderDynamicAddress(PROXY_UPDATE));
66 operations.batch(proxyAdd).assertSuccess();
67 operations.add(customLoadMetricAddress(PROXY_UPDATE, CUSTOM_LOAD_METRIC_DELETE), Values.of(CLASS, CLASS_NAME))
68 .assertSuccess();
69 operations.add(customLoadMetricAddress(PROXY_UPDATE, CUSTOM_LOAD_METRIC_UPDATE), Values.of(CLASS, CLASS_NAME))
70 .assertSuccess();
71 }
72
73 @Inject Console console;
74 @Inject CrudOperations crud;
75 @Page ModclusterPage page;
76 TableFragment table;
77 FormFragment form;
78
79 @BeforeEach
80 void setUp() {
81 page.navigate(NAME, PROXY_UPDATE);
82 console.verticalNavigation().selectPrimary("custom-load-metrics-item");
83 table = page.getCustomLoadMetricTable();
84 form = page.getCustomLoadMetricForm();
85 table.bind(form);
86 }
87
88 @Test
89 void create() throws Exception {
90 crud.create(customLoadMetricAddress(PROXY_UPDATE, CUSTOM_LOAD_METRIC_CREATE), table, f -> {
91 f.text(NAME, CUSTOM_LOAD_METRIC_CREATE);
92 f.text(CLASS, CLASS_NAME);
93 },
94 ver -> ver.verifyAttribute(CLASS, CLASS_NAME));
95 }
96
97 @Test
98 void reset() throws Exception {
99 table.select(CUSTOM_LOAD_METRIC_UPDATE);
100 crud.reset(customLoadMetricAddress(PROXY_UPDATE, CUSTOM_LOAD_METRIC_UPDATE), form);
101 }
102
103 @Test
104 void update() throws Exception {
105 table.select(CUSTOM_LOAD_METRIC_UPDATE);
106 crud.update(customLoadMetricAddress(PROXY_UPDATE, CUSTOM_LOAD_METRIC_UPDATE), form, WEIGHT, Random.number());
107 }
108
109 @Test
110 void updateCapacity() throws Exception {
111
112 table.select(CUSTOM_LOAD_METRIC_UPDATE);
113 crud.update(customLoadMetricAddress(PROXY_UPDATE, CUSTOM_LOAD_METRIC_UPDATE), form, "capacity",
114 Random.numberDouble());
115 }
116
117 @Test
118 void delete() throws Exception {
119 crud.delete(customLoadMetricAddress(PROXY_UPDATE, CUSTOM_LOAD_METRIC_DELETE), table, CUSTOM_LOAD_METRIC_DELETE);
120 }
121 }