1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.hal.testsuite.test.configuration.web;
17
18 import org.jboss.arquillian.core.api.annotation.Inject;
19 import org.jboss.arquillian.graphene.page.Page;
20 import org.jboss.hal.resources.Ids;
21 import org.jboss.hal.testsuite.Console;
22 import org.jboss.hal.testsuite.CrudOperations;
23 import org.jboss.hal.testsuite.Random;
24 import org.jboss.hal.testsuite.container.WildFlyContainer;
25 import org.jboss.hal.testsuite.fragment.FormFragment;
26 import org.jboss.hal.testsuite.fragment.TableFragment;
27 import org.jboss.hal.testsuite.page.configuration.FilterPage;
28 import org.jboss.hal.testsuite.test.Manatoko;
29 import org.junit.jupiter.api.BeforeAll;
30 import org.junit.jupiter.api.BeforeEach;
31 import org.junit.jupiter.api.Test;
32 import org.testcontainers.junit.jupiter.Container;
33 import org.testcontainers.junit.jupiter.Testcontainers;
34 import org.wildfly.extras.creaper.core.online.operations.Operations;
35 import org.wildfly.extras.creaper.core.online.operations.Values;
36
37 import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
38 import static org.jboss.hal.dmr.ModelDescriptionConstants.QUEUE_SIZE;
39 import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
40 import static org.jboss.hal.testsuite.fixtures.WebFixtures.FILTER_CREATE;
41 import static org.jboss.hal.testsuite.fixtures.WebFixtures.FILTER_DELETE;
42 import static org.jboss.hal.testsuite.fixtures.WebFixtures.FILTER_UPDATE;
43 import static org.jboss.hal.testsuite.fixtures.WebFixtures.MAX_CONCURRENT_REQUESTS;
44 import static org.jboss.hal.testsuite.fixtures.WebFixtures.requestLimitAddress;
45
46 @Manatoko
47 @Testcontainers
48 public class RequestLimitTest {
49
50 @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
51
52 @BeforeAll
53 static void setupModel() throws Exception {
54 Operations operations = new Operations(wildFly.managementClient());
55 operations.add(requestLimitAddress(FILTER_UPDATE), Values.of(MAX_CONCURRENT_REQUESTS, Random.number()));
56 operations.add(requestLimitAddress(FILTER_DELETE), Values.of(MAX_CONCURRENT_REQUESTS, Random.number()));
57 }
58
59 @Inject Console console;
60 @Page FilterPage page;
61 @Inject CrudOperations crud;
62 TableFragment table;
63 FormFragment form;
64
65 @BeforeEach
66 void prepare() {
67 page.navigate();
68 console.verticalNavigation().selectPrimary(Ids.build("undertow-request-limit", "item"));
69 table = page.getRequestLimitTable();
70 form = page.getRequestLimitForm();
71 table.bind(form);
72 }
73
74 @Test
75 void create() throws Exception {
76 crud.create(requestLimitAddress(FILTER_CREATE), table, form -> {
77 form.text(NAME, FILTER_CREATE);
78 form.number(MAX_CONCURRENT_REQUESTS, Random.number());
79 });
80 }
81
82 @Test
83 void update() throws Exception {
84 int requests = Random.number();
85 int queue = Random.number();
86
87 table.select(FILTER_UPDATE);
88 crud.update(requestLimitAddress(FILTER_UPDATE), form, f -> {
89 f.number(MAX_CONCURRENT_REQUESTS, requests);
90 f.number(QUEUE_SIZE, queue);
91 }, resourceVerifier -> {
92 resourceVerifier.verifyAttribute(MAX_CONCURRENT_REQUESTS, requests);
93 resourceVerifier.verifyAttribute(QUEUE_SIZE, queue);
94 });
95 }
96
97 @Test
98 void delete() throws Exception {
99 crud.delete(requestLimitAddress(FILTER_DELETE), table, FILTER_DELETE);
100 }
101 }