View Javadoc
1   /*
2    *  Copyright 2022 Red Hat
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.jboss.hal.testsuite.test.configuration.jgroups;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.resources.Names;
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.JGroupsPage;
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.MethodOrderer;
32  import org.junit.jupiter.api.Test;
33  import org.junit.jupiter.api.TestMethodOrder;
34  import org.testcontainers.junit.jupiter.Container;
35  import org.testcontainers.junit.jupiter.Testcontainers;
36  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
37  import org.wildfly.extras.creaper.core.online.operations.Batch;
38  import org.wildfly.extras.creaper.core.online.operations.Operations;
39  import org.wildfly.extras.creaper.core.online.operations.Values;
40  
41  import static org.jboss.arquillian.graphene.Graphene.waitGui;
42  import static org.jboss.hal.dmr.ModelDescriptionConstants.CHANNEL;
43  import static org.jboss.hal.dmr.ModelDescriptionConstants.EE;
44  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
45  import static org.jboss.hal.dmr.ModelDescriptionConstants.RELAY;
46  import static org.jboss.hal.dmr.ModelDescriptionConstants.SOCKET_BINDING;
47  import static org.jboss.hal.dmr.ModelDescriptionConstants.STACK;
48  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.HA;
49  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.CHANNEL_CREATE;
50  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.JGROUPS_TCP;
51  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.REMOTESITE_CREATE;
52  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.REMOTESITE_DELETE;
53  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.REMOTESITE_UPDATE;
54  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.SITE;
55  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.STACK_CREATE;
56  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.TCP;
57  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.TRANSPORT_CREATE;
58  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.channelAddress;
59  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.relayAddress;
60  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.relayRemoteSiteAddress;
61  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.stackAddress;
62  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.transportAddress;
63  
64  @Manatoko
65  @Testcontainers
66  @TestMethodOrder(MethodOrderer.MethodName.class)
67  class StackRelayRemoteSiteTest {
68  
69      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(HA);
70  
71      @BeforeAll
72      static void setupModel() throws Exception {
73          OnlineManagementClient client = wildFly.managementClient();
74          Operations operations = new Operations(client);
75          Batch stackCreate = new Batch();
76          stackCreate.add(stackAddress(STACK_CREATE));
77          stackCreate.add(transportAddress(STACK_CREATE, TRANSPORT_CREATE), Values.of(SOCKET_BINDING, JGROUPS_TCP));
78          operations.batch(stackCreate);
79          operations.add(channelAddress(CHANNEL_CREATE), Values.of(STACK, TCP));
80          operations.add(relayAddress(STACK_CREATE), Values.of(SITE, Random.name()));
81          operations.add(relayRemoteSiteAddress(STACK_CREATE, REMOTESITE_UPDATE), Values.of(CHANNEL, EE));
82          operations.add(relayRemoteSiteAddress(STACK_CREATE, REMOTESITE_DELETE), Values.of(CHANNEL, EE));
83      }
84  
85      @Inject Console console;
86      @Inject CrudOperations crud;
87      @Page JGroupsPage page;
88      TableFragment stackTable;
89      TableFragment relayTable;
90      TableFragment remoteSiteTable;
91      FormFragment remoteSiteForm;
92  
93      @BeforeEach
94      void setUp() {
95          page.navigate();
96          console.verticalNavigation().selectPrimary("jgroups-stack-item");
97  
98          stackTable = page.getStackTable();
99          relayTable = page.getRelayTable();
100         remoteSiteTable = page.getRelayRemoteSiteTable();
101         remoteSiteForm = page.getRelayRemoteSiteForm();
102         remoteSiteTable.bind(remoteSiteForm);
103     }
104 
105     @Test
106     void create() throws Exception {
107         stackTable.action(STACK_CREATE, Names.RELAY);
108         waitGui().until().element(relayTable.getRoot()).is().visible();
109 
110         relayTable.select(RELAY.toUpperCase());
111         relayTable.action(RELAY.toUpperCase(), Names.REMOTE_SITE);
112         waitGui().until().element(remoteSiteTable.getRoot()).is().visible();
113 
114         crud.create(relayRemoteSiteAddress(STACK_CREATE, REMOTESITE_CREATE), remoteSiteTable,
115                 form -> {
116                     form.text(NAME, REMOTESITE_CREATE);
117                     form.text(CHANNEL, EE);
118                 },
119                 resourceVerifier -> resourceVerifier.verifyAttribute(CHANNEL, EE));
120     }
121 
122     @Test()
123     void update() throws Exception {
124         stackTable.action(STACK_CREATE, Names.RELAY);
125         waitGui().until().element(relayTable.getRoot()).is().visible();
126 
127         relayTable.select(RELAY.toUpperCase());
128         relayTable.action(RELAY.toUpperCase(), Names.REMOTE_SITE);
129         waitGui().until().element(remoteSiteTable.getRoot()).is().visible();
130 
131         remoteSiteTable.select(REMOTESITE_UPDATE);
132         crud.update(relayRemoteSiteAddress(STACK_CREATE, REMOTESITE_UPDATE), remoteSiteForm, CHANNEL, CHANNEL_CREATE);
133     }
134 
135     @Test()
136     void updateEmptyEE() {
137         stackTable.action(STACK_CREATE, Names.RELAY);
138         waitGui().until().element(relayTable.getRoot()).is().visible();
139 
140         relayTable.select(RELAY.toUpperCase());
141         relayTable.action(RELAY.toUpperCase(), Names.REMOTE_SITE);
142         waitGui().until().element(remoteSiteTable.getRoot()).is().visible();
143 
144         remoteSiteTable.select(REMOTESITE_UPDATE);
145         crud.updateWithError(remoteSiteForm, form -> form.clear(CHANNEL), CHANNEL);
146     }
147 
148     @Test
149     void remove() throws Exception {
150         stackTable.action(STACK_CREATE, Names.RELAY);
151         waitGui().until().element(relayTable.getRoot()).is().visible();
152 
153         relayTable.select(RELAY.toUpperCase());
154         relayTable.action(RELAY.toUpperCase(), Names.REMOTE_SITE);
155         waitGui().until().element(remoteSiteTable.getRoot()).is().visible();
156 
157         crud.delete(relayRemoteSiteAddress(STACK_CREATE, REMOTESITE_DELETE), remoteSiteTable, REMOTESITE_DELETE);
158     }
159 }