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.transaction;
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.fixtures.TransactionFixtures;
26  import org.jboss.hal.testsuite.page.configuration.TransactionPage;
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.Disabled;
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  
36  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
37  
38  @Manatoko
39  @Testcontainers
40  class ConfigurationTest {
41  
42      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
43      private static Operations operations;
44  
45      @BeforeAll
46      static void setupModel() {
47          operations = new Operations(wildFly.managementClient());
48      }
49  
50      @Inject Console console;
51      @Inject CrudOperations crudOperations;
52      @Page TransactionPage page;
53  
54      @BeforeEach
55      public void prepare() {
56          page.navigate();
57          console.verticalNavigation()
58                  .selectPrimary(Ids.build("tx", "attributes", "config", "item"));
59      }
60  
61      @Test
62      public void editDefaultTimeout() throws Exception {
63          crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getConfigurationForm(),
64                  TransactionFixtures.DEFAULT_TIMEOUT,
65                  Random.number());
66      }
67  
68      @Test
69      public void toggleEnableTsmStatus() throws Exception {
70          boolean enableTsmStatus = operations
71                  .readAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS, TransactionFixtures.ENABLE_TSM_STATUS)
72                  .booleanValue();
73          crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getConfigurationForm(),
74                  TransactionFixtures.ENABLE_TSM_STATUS,
75                  !enableTsmStatus);
76      }
77  
78      @Test
79      public void toggleJournalStoreEnableAsyncIO() throws Exception {
80          boolean journalStoreEnableAsyncIO = operations.readAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS,
81                  TransactionFixtures.JOURNAL_STORE_ENABLE_ASYNC_IO)
82                  .booleanValue();
83          crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getConfigurationForm(), formFragment -> {
84              formFragment.flip(TransactionFixtures.USE_JOURNAL_STORE, !journalStoreEnableAsyncIO);
85              formFragment.flip(TransactionFixtures.JOURNAL_STORE_ENABLE_ASYNC_IO, !journalStoreEnableAsyncIO);
86          }, resourceVerifier -> resourceVerifier.verifyAttribute(TransactionFixtures.JOURNAL_STORE_ENABLE_ASYNC_IO,
87                  !journalStoreEnableAsyncIO));
88      }
89  
90      @Test
91      public void toggleJTS() throws Exception {
92          boolean jts = operations.readAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS, TransactionFixtures.JTS)
93                  .booleanValue();
94          crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getConfigurationForm(),
95                  TransactionFixtures.JTS,
96                  !jts);
97      }
98  
99      @Test
100     public void editNodeIdentifier() throws Exception {
101         crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getConfigurationForm(), "node-identifier",
102                 Random.name());
103     }
104 
105     // TODO: recent wildfly uses an expression for this value and the flip operation should switch to normal mode
106     // before flipping
107     @Test
108     @Disabled
109     public void toggleStatisticsEnabled() throws Exception {
110         boolean statisticsEnabled = operations
111                 .readAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS, TransactionFixtures.STATISTICS_ENABLED)
112                 .booleanValue();
113         crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getConfigurationForm(),
114                 TransactionFixtures.STATISTICS_ENABLED,
115                 !statisticsEnabled);
116     }
117 
118     @Test
119     public void toggleUseJournalStore() throws Exception {
120         boolean useJournalStore = operations
121                 .readAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS, TransactionFixtures.USE_JOURNAL_STORE)
122                 .booleanValue();
123         boolean journalStoreEnableAsyncIO = operations.readAttribute(TransactionFixtures.TRANSACTIONS_ADDRESS,
124                 TransactionFixtures.JOURNAL_STORE_ENABLE_ASYNC_IO)
125                 .booleanValue();
126         crudOperations.update(TransactionFixtures.TRANSACTIONS_ADDRESS, page.getConfigurationForm(), formFragment -> {
127             formFragment.flip(TransactionFixtures.USE_JOURNAL_STORE, !useJournalStore);
128             if (journalStoreEnableAsyncIO) {
129                 formFragment.flip(TransactionFixtures.JOURNAL_STORE_ENABLE_ASYNC_IO, false);
130             }
131         }, resourceVerifier -> resourceVerifier.verifyAttribute(TransactionFixtures.USE_JOURNAL_STORE,
132                 !useJournalStore));
133     }
134 }