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.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.EmptyState;
25  import org.jboss.hal.testsuite.fragment.FormFragment;
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.Operations;
35  import org.wildfly.extras.creaper.core.online.operations.Values;
36  
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.DEFAULT;
38  import static org.jboss.hal.dmr.ModelDescriptionConstants.LISTENER;
39  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
40  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.HA;
41  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.FACTOR;
42  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.PROXY_SIMPLE_LP;
43  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.loadProviderSimpleAddress;
44  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.proxyAddress;
45  import static org.junit.jupiter.api.Assertions.assertTrue;
46  
47  @Manatoko
48  @Testcontainers
49  class ModclusterLoadProviderSimpleTest {
50  
51      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(HA);
52  
53      @BeforeAll
54      static void setupModel() throws Exception {
55          OnlineManagementClient client = wildFly.managementClient();
56          Operations operations = new Operations(client);
57          operations.add(proxyAddress(PROXY_SIMPLE_LP), Values.of(LISTENER, DEFAULT));
58          operations.add(loadProviderSimpleAddress(PROXY_SIMPLE_LP));
59      }
60  
61      @Inject Console console;
62      @Inject CrudOperations crud;
63      @Page ModclusterPage page;
64      FormFragment form;
65  
66      @BeforeEach
67      void setUp() {
68          page.navigate(NAME, PROXY_SIMPLE_LP);
69          console.verticalNavigation().selectPrimary("load-provider-simple-item");
70          form = page.getLoadProviderSimpleForm();
71      }
72  
73      @Test
74      void noDynamicProvider() {
75          console.verticalNavigation().selectPrimary("load-provider-dynamic-item");
76          EmptyState empty = page.getLoadProviderDynamicEmpty();
77          assertTrue(empty.getRoot().isDisplayed());
78      }
79  
80      @Test
81      void customLoadMetricsWarning() {
82          console.verticalNavigation().selectPrimary("custom-load-metrics-item");
83          assertTrue(page.getCustomLoadMetricAlert().isWarning());
84      }
85  
86      @Test
87      void loadMetricsWarning() {
88          console.verticalNavigation().selectPrimary("load-metrics-item");
89          assertTrue(page.getLoadMetricAlert().isWarning());
90      }
91  
92      @Test
93      void reset() throws Exception {
94          crud.reset(loadProviderSimpleAddress(PROXY_SIMPLE_LP), form);
95      }
96  
97      @Test
98      void update() throws Exception {
99          crud.update(loadProviderSimpleAddress(PROXY_SIMPLE_LP), form, FACTOR, Random.number());
100     }
101 }