diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index c73aa8985..33d9b955b 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: 18.17.0 + node-version: 18.18.0 cache: 'npm' - name: Install @@ -57,13 +57,13 @@ jobs: docker exec $(docker ps -q -l) /opt/infinispan/bin/cli.sh install org.ow2.asm:asm-tree:9.4 docker exec $(docker ps -q -l) /opt/infinispan/bin/cli.sh install org.ow2.asm:asm-util:9.4 - - name: Restarting Infnispan Server After Nashorn Installation + - name: Restarting Infinispan Server After Nashorn Installation run: | docker restart $(docker ps -q -l) # Wait for server to startup curl --fail --silent --show-error --retry-all-errors --retry 240 --retry-delay 1 http://localhost:11222/rest/v2/cache-managers/default/health/status > /dev/null - - name: Initialize Infnispan Server + - name: Initialize Infinispan Server run: cd data; bash ./create-data.sh admin password - name: Cypress run diff --git a/README.md b/README.md index a7bb8a5ac..fba1ea1f3 100644 --- a/README.md +++ b/README.md @@ -70,10 +70,10 @@ Integration tests don't run by default locally. They always run in CI. To run Cypress integration tests locally, follow these steps: -1. Run the Infinispan server using `./run-server-for-e2e.sh`, which will download and run the server. -2. Run the following command with the `-De2e=true` flag: -```bash -mvn clean install -De2e=true +```shell +npm run build # build the console +./run-server-for-e2e-container.sh # will run the latest image of Infinispan for this branch version and the built console +npm run cy:e2e # will run cypress locally ``` ## Configurations diff --git a/cypress/e2e/cluster-welcome.cy.js b/cypress/e2e/1_cluster-welcome.cy.js similarity index 98% rename from cypress/e2e/cluster-welcome.cy.js rename to cypress/e2e/1_cluster-welcome.cy.js index cd6613502..5144fbd8c 100644 --- a/cypress/e2e/cluster-welcome.cy.js +++ b/cypress/e2e/1_cluster-welcome.cy.js @@ -17,7 +17,7 @@ describe('Welcome page', () => { cy.contains('Default'); // cluster name cy.contains('Running'); // cluster status cy.contains('Cluster rebalancing on'); // rebalancing status - cy.contains('18 Caches'); + cy.contains('15 Caches'); cy.contains('10 Counters'); cy.contains('1 Tasks'); cy.contains('13 Schemas'); @@ -72,7 +72,7 @@ describe('Welcome page', () => { cy.login(Cypress.env('username'), Cypress.env('password')); cy.get('[data-cy=aboutInfoQuestionMark]').click(); cy.contains('Documentation'); - + //Clicks the About link and should go to About dialog cy.contains('About').click(); cy.get('[role=dialog]').should('be.visible'); diff --git a/cypress/e2e/data-container.cy.js b/cypress/e2e/1_data-container.cy.js similarity index 87% rename from cypress/e2e/data-container.cy.js rename to cypress/e2e/1_data-container.cy.js index aff34ffe4..3814a2a38 100644 --- a/cypress/e2e/data-container.cy.js +++ b/cypress/e2e/1_data-container.cy.js @@ -1,5 +1,5 @@ describe('Data Container Overview', () => { - const numberOfCaches = 18; + const numberOfCaches = 15; beforeEach(() => { cy.login(Cypress.env('username'), Cypress.env('password')); @@ -32,7 +32,7 @@ describe('Data Container Overview', () => { //Testing pagination and navigation it('successfully navigates through the caches as well as changes number of viewed caches on the page', () => { cy.contains(numberOfCaches + ' Caches'); - cy.contains('12 Counters'); + cy.contains('10 Counters'); cy.contains('1 Tasks'); cy.contains('13 Schemas'); @@ -121,7 +121,7 @@ describe('Data Container Overview', () => { //Verifying that only local caches are shown cy.contains('default'); - cy.get('[data-cy=cachesTable] tr').should('have.length', 3); //3 including header row + cy.get('[data-cy=cachesTable] tr').should('have.length', 2); //2 including header row //Verifying that all entries are local caches cy.get('[data-cy^=type-]').each((badge) => { cy.wrap(badge).contains('Local'); @@ -171,12 +171,12 @@ describe('Data Container Overview', () => { cy.get('[data-cy=cacheFilterSelect]').click(); //Verifying that only distributed caches are shown - cy.contains('1 - 10 of 14'); + cy.contains('1 - 10 of 12'); cy.contains('java-serialized-cache'); cy.get('[data-cy=cachesTable] tr').should('have.length', 11); //11 including header row //Navigating to the next page to see the rest of the caches cy.get('[data-action=next]').first().click(); - cy.get('[data-cy=cachesTable] tr').should('have.length', 5); //5 including header row + cy.get('[data-cy=cachesTable] tr').should('have.length', 3); //3 including header row cy.contains('xml-cache'); cy.contains('java-serialized-cache').should('not.exist'); @@ -185,8 +185,8 @@ describe('Data Container Overview', () => { cy.get('[data-action=per-page-20]').click(); cy.contains('not-encoded'); cy.contains('xml-cache'); - cy.contains('1 - 14 of 14'); - cy.get('[data-cy=cachesTable] tr').should('have.length', 15); //15 including header row + cy.contains('1 - 12 of 12'); + cy.get('[data-cy=cachesTable] tr').should('have.length', 13); //13 including header row //Verifying that all entries are distributed caches cy.get('[data-cy^=type-]').each((badge) => { @@ -198,7 +198,7 @@ describe('Data Container Overview', () => { cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); cy.get('[data-cy="transactionalFeature"]').find('input:checkbox').click(); //Filtering transactional caches (already on filtered distributed caches) cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox - cy.get('[data-cy=cachesTable] tr').should('have.length', 5); //5 including header row + cy.get('[data-cy=cachesTable] tr').should('have.length', 4); //4 including header row // //Verifying that all entries are distributed and transactional caches cy.get('[data-cy^=type-]').each((badge) => { cy.wrap(badge).contains('Distributed'); @@ -209,13 +209,12 @@ describe('Data Container Overview', () => { cy.contains('heap-test'); cy.contains('off-heap-test'); cy.contains('people'); - cy.contains('super-cache'); // //Adding Replicated type filter cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); cy.get('[data-cy="replicatedType"]').find('input:checkbox').click(); //Filtering transactional caches (already on filtered distributed caches)+replicated cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox - cy.get('[data-cy=cachesTable] tr').should('have.length', 5); //5 including header row - nothing is changed + cy.get('[data-cy=cachesTable] tr').should('have.length', 4); //4 including header row - nothing is changed //Verifying that all entries are distributed and transactional caches cy.get('[data-cy^=type-]').each((badge) => { cy.wrap(badge).contains('Distributed'); @@ -226,7 +225,6 @@ describe('Data Container Overview', () => { cy.contains('heap-test'); cy.contains('off-heap-test'); cy.contains('people'); - cy.contains('super-cache'); //Removing Distributed filter cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); @@ -239,7 +237,7 @@ describe('Data Container Overview', () => { cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); cy.get('[data-cy="replicatedType"]').find('input:checkbox').click(); //Filtering transactional caches & replicated ones cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox - cy.get('[data-cy=cachesTable] tr').should('have.length', 5); //5 including header row - nothing is changed + cy.get('[data-cy=cachesTable] tr').should('have.length', 4); //4 including header row - nothing is changed cy.get('[data-cy^=feature-]').each((badge) => { cy.wrap(badge).contains('Transactional'); }); @@ -248,7 +246,7 @@ describe('Data Container Overview', () => { cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); cy.get('[data-cy="indexedFeature"]').find('input:checkbox').click(); //Filtering transactional caches & replicated ones cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox - cy.get('[data-cy=cachesTable] tr').should('have.length', 7); //7 including header row - nothing is changed + cy.get('[data-cy=cachesTable] tr').should('have.length', 7); //5 including header row - nothing is changed cy.get('[data-cy^=feature-]').each((badge) => { cy.wrap(badge).contains(/Transactional|Indexed/); }); @@ -269,7 +267,6 @@ describe('Data Container Overview', () => { cy.wrap(badge).contains(/Secured/); }); cy.contains('indexed-cache'); - cy.contains('super-cache'); //Clearing all filters and setting Persistence cy.get('button:contains("Clear all filters"):visible').click(); @@ -280,94 +277,66 @@ describe('Data Container Overview', () => { cy.get('[data-cy^=feature-]').each((badge) => { cy.wrap(badge).contains(/Persistent/); }); - cy.contains('super-cache'); //Adding Bounded filter cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); cy.get('[data-cy="boundedFeature"]').find('input:checkbox').click(); //Filtering bounded caches cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox - cy.get('[data-cy=cachesTable] tr').should('have.length', 4); //4 including header row - nothing is changed + cy.get('[data-cy=cachesTable] tr').should('have.length', 3); //3 including header row - nothing is changed cy.get('[data-cy^=feature-]').each((badge) => { cy.wrap(badge).contains(/Bounded/); }); - cy.contains('super-cache'); cy.contains('heap-test'); }); //Hide created cache and check the hidden filter it('successfully ignores the cache', () => { - cy.get('[data-cy=actions-aCache]').click(); + cy.get('[data-cy=actions-default]').click(); cy.get('[aria-label=ignoreCacheAction]').click(); cy.get('[data-cy=ignoreCacheModal]').should('exist'); cy.get('#hideShowModal [aria-label=Close]').click(); //Closing modal with close button cy.get('[data-cy=ignoreCacheModal]').should('not.exist'); - cy.get('[data-cy=actions-aCache]').click(); + cy.get('[data-cy=actions-default]').click(); cy.get('[aria-label=ignoreCacheAction]').click(); cy.get('[data-cy=ignoreCacheModal]').should('exist'); cy.get('[data-cy=cancelAction]').click(); //Closing modal with Cancel button cy.get('[data-cy=ignoreCacheModal]').should('not.exist'); - cy.get('[data-cy=actions-aCache]').click(); + cy.get('[data-cy=actions-default]').click(); cy.get('[aria-label=ignoreCacheAction]').click(); cy.get('[data-cy=hideCacheButton]').click(); //Hiding cache - cy.contains('Cache aCache hidden.').should('exist'); - cy.get('[data-cy=ignoreBadge-aCache]').should('exist'); + cy.contains('Cache default hidden.').should('exist'); + cy.get('[data-cy=ignoreBadge-default]').should('exist'); cy.get('[data-cy=cacheFilterSelect]').click(); cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); cy.get('[data-cy="hiddenStatus"]').find('input:checkbox').click(); //Filtering hidden caches cy.get('[data-cy=cacheFilterSelect]').click(); //Closing filter selectbox cy.get('[data-cy=cachesTable] tr').should('have.length', 2); //2 including header row - nothing is changed - cy.get('[data-cy=ignoreBadge-aCache]').should('exist'); - cy.contains('aCache'); + cy.get('[data-cy=ignoreBadge-default]').should('exist'); + cy.contains('default'); }); //Show (undo ignored cache) created cache it('successfully undos the ignore the cache action', () => { - cy.get('[data-cy=actions-aCache]').click(); + cy.get('[data-cy=actions-default]').click(); cy.get('[aria-label=showCacheAction]').click(); cy.get('[data-cy=undoCacheModal]').should('exist'); cy.get('#hideShowModal [aria-label=Close]').click(); //Closing modal with close button cy.get('[data-cy=undoCacheModal]').should('not.exist'); - cy.get('[data-cy=actions-aCache]').click(); + cy.get('[data-cy=actions-default]').click(); cy.get('[aria-label=showCacheAction]').click(); cy.get('[data-cy=undoCacheModal]').should('exist'); cy.get('[data-cy=cancelAction]').click(); //Closing modal with Cancel button cy.get('[data-cy=undoCacheModal]').should('not.exist'); - cy.get('[data-cy=actions-aCache]').click(); + cy.get('[data-cy=actions-default]').click(); cy.get('[aria-label=showCacheAction]').click(); cy.get('[data-cy=showCacheButton]').click(); //Hiding cache - cy.contains('Cache aCache is now visible.').should('exist'); - cy.get('[data-cy=ignoreBadge-aCache]').should('not.exist'); - }); - - //Delete created cache - it('successfully deletes a cache', () => { - cy.get('[data-cy=actions-aCache]').click(); - cy.get('[aria-label=deleteCacheAction]').click(); - cy.get('#deleteCacheModal').should('exist'); - cy.contains('Permanently delete cache?'); - cy.get('#deleteCacheModal [aria-label=Close]').click(); //Closing modal with close button - cy.contains('Permanently delete cache?').should('not.exist'); - - cy.get('[data-cy=actions-aCache]').click(); - cy.get('[aria-label=deleteCacheAction]').click(); - cy.contains('Permanently delete cache?'); - cy.get('[data-cy=cancelCacheDeleteButton]').click(); //Closing modal with Cancel button - cy.contains('Permanently delete cache?').should('not.exist'); - - cy.get('[data-cy=actions-aCache]').click(); - cy.get('[aria-label=deleteCacheAction]').click(); - cy.get('#cache-to-delete').click(); - cy.get('#cache-to-delete').type('aCache'); - cy.get('[data-cy=deleteCacheButton]').click(); //Deleting cache aCache - - cy.contains('Cache aCache deleted.'); - cy.get('.pf-v5-c-alert__action > .pf-v5-c-button').click(); //Closing alert popup. - cy.get('aCache').should('not.exist'); //Checking that deleted cache is not visible + cy.contains('Cache default is now visible.').should('exist'); + cy.get('[data-cy=ignoreBadge-default]').should('not.exist'); }); // Displays templates page diff --git a/cypress/e2e/global-stats.cy.js b/cypress/e2e/1_global-stats.cy.js similarity index 100% rename from cypress/e2e/global-stats.cy.js rename to cypress/e2e/1_global-stats.cy.js diff --git a/cypress/e2e/rbac_func.cy.js b/cypress/e2e/1_rbac_func.cy.js similarity index 80% rename from cypress/e2e/rbac_func.cy.js rename to cypress/e2e/1_rbac_func.cy.js index be720be96..a677a5443 100644 --- a/cypress/e2e/rbac_func.cy.js +++ b/cypress/e2e/1_rbac_func.cy.js @@ -1,4 +1,4 @@ -describe('RBAC Functionlity Tests', () => { +describe('RBAC Functionality Tests', () => { const monitorUserName = 'monitor'; const observerUserName = 'observer'; const applicationUserName = 'application'; @@ -8,13 +8,16 @@ describe('RBAC Functionlity Tests', () => { cy.login(monitorUserName, Cypress.env('password')); checkDataContainerView(true, false, false, false); checkSecuredCacheDetailsView(true, false, false, 'monitor', 'indexed-cache'); - checkNotOwnSecuredCache('super-cache'); + checkNotOwnSecuredCache('a-rbac-test-cache'); checkNonSecuredCacheDetailView(true, false); + checkMenu(false); + cy.login(monitorUserName, Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(false); }); it('successfully logins and performs actions with observer user', () => { cy.login(observerUserName, Cypress.env('password')); - + checkMenu(false); checkDataContainerView(false, false, false, false); checkSecuredCacheDetailsView(false, false, false, 'observer', 'indexed-cache'); cy.contains('Elaia'); @@ -26,18 +29,21 @@ describe('RBAC Functionlity Tests', () => { cy.contains('1 - 1 of 1'); cy.contains('Elaia'); - checkNotOwnSecuredCache('super-cache'); + checkNotOwnSecuredCache('a-rbac-test-cache'); checkNonSecuredCacheDetailView(false, false); //Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix) checkSchemasPageView(false); checkCountersPageView(); + cy.login(observerUserName, Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(false); }); it('successfully logins and performs actions with application user', () => { cy.login(applicationUserName, Cypress.env('password')); + checkMenu(false); checkDataContainerView(false, false, false, false); - checkSecuredCacheDetailsView(false, true, false, 'application', 'super-cache'); + checkSecuredCacheDetailsView(false, true, false, 'application', 'a-rbac-test-cache'); checkActionsOnSuperCache(); checkNotOwnSecuredCache('indexed-cache'); @@ -45,13 +51,16 @@ describe('RBAC Functionlity Tests', () => { //Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix) checkSchemasPageView(false); checkCountersPageView(); + cy.login(applicationUserName, Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(false); }); it('successfully logins and performs actions with deployer user', () => { cy.login(deployerUserName, Cypress.env('password')); + checkMenu(false); checkDataContainerView(false, true, true, false); - checkSecuredCacheDetailsView(false, true, false, 'deployer', 'super-cache'); + checkSecuredCacheDetailsView(false, true, false, 'deployer', 'a-rbac-test-cache'); checkActionsOnSuperCache(); checkNotOwnSecuredCache('indexed-cache'); @@ -59,13 +68,16 @@ describe('RBAC Functionlity Tests', () => { //Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix) checkSchemasPageView(true); checkCountersPageView(); + cy.login(monitorUserName, Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(monitorUserName); }); it('successfully logins and performs actions with admin user', () => { cy.login(Cypress.env('username'), Cypress.env('password')); + checkMenu(true); checkDataContainerView(false, true, true, true); - checkSecuredCacheDetailsView(false, true, true, 'admin', 'super-cache'); + checkSecuredCacheDetailsView(false, true, true, 'admin', 'a-rbac-test-cache'); checkActionsOnSuperCache(); checkNotOwnSecuredCache('text-cache'); @@ -74,8 +86,24 @@ describe('RBAC Functionlity Tests', () => { checkSchemasPageView(true); checkCountersPageView(); checkTasksPage(); + cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(true); }); + function checkMenu(isSuperAdmin) { + if (isSuperAdmin) { + cy.contains('Data Container').should('exist'); + cy.contains('Global Statistics').should('exist'); + cy.contains('Cluster Membership').should('exist'); + cy.contains('Connected Clients').should('exist'); + } else { + cy.contains('Data Container').should('exist'); + cy.contains('Global Statistics').should('exist'); + cy.contains('Cluster Membership').should('exist'); + cy.contains('Connected Clients').should('not.exist'); + } + } + function checkDataContainerView(isMonitor, isDeployer, isAdmin, isSuperAdmin) { //Checking Data Container view cy.contains('Default'); // cluster name @@ -90,13 +118,13 @@ describe('RBAC Functionlity Tests', () => { cy.get('[data-cy=cacheManagerStatus]').should('exist'); cy.get('[data-cy=navigationTabs]').should('exist'); cy.contains(/^\d+ Caches$/); - cy.contains('10 Counters'); + cy.contains('Counters'); if (isMonitor) { - cy.contains('1 Tasks').should('not.exist'); - cy.contains('13 Schemas').should('not.exist'); + cy.contains('Tasks').should('not.exist'); + cy.contains('Schemas').should('not.exist'); } else { //cy.contains('1 Tasks'); //Should be uncommented after feature is implemented - cy.contains('13 Schemas'); + cy.contains('Schemas'); } cy.get('#cache-table-toolbar').should('exist'); cy.get('[data-cy=paginationArea]').should('exist'); @@ -140,8 +168,10 @@ describe('RBAC Functionlity Tests', () => { if (isSuperAdmin) { cy.get('#rebalancing-switch').should('exist'); + cy.get('[data-cy=cacheConfigurationTab]').should('exist'); } else { cy.get('#rebalancing-switch').should('not.exist'); + cy.get('[data-cy=cacheConfigurationTab]').should('not.exist'); } if (isMonitor) { @@ -152,10 +182,6 @@ describe('RBAC Functionlity Tests', () => { cy.get('[data-cy=queriesTab]').should('exist'); } - //Checking cache configuration page - cy.get('[data-cy=cacheConfigurationTab]').click(); - cy.contains('authorization'); - cy.contains(roleName); cy.get('[data-cy=manageIndexesLink]').click(); if (isSuperAdmin) { cy.get('[data-cy=clearIndexButton]').should('exist'); @@ -166,11 +192,12 @@ describe('RBAC Functionlity Tests', () => { cy.get('[data-cy=backButton]').click(); //Going to metrics page cy.get('[data-cy=cacheMetricsTab]').click(); - cy.get('[data-cy=data-distribution-chart]').should('exist'); if (isSuperAdmin) { + cy.get('[data-cy=data-distribution-chart]').should('exist'); cy.get('[data-cy=clearQueryMetricsButton]').should('exist'); } else { cy.get('[data-cy=clearQueryMetricsButton]').should('not.exist'); + cy.get('[data-cy=data-distribution-chart]').should('not.exist'); } if (!isMonitor) @@ -183,7 +210,7 @@ describe('RBAC Functionlity Tests', () => { cy.contains('Data container').click(); cy.get('[id^="pagination-caches-top-pagination"]').first().click(); cy.get('[data-action=per-page-100]').click(); - cy.contains(/cacheName$/).should('not.exist'); + cy.contains('/' + cacheName +'$/').should('not.exist'); } function checkNonSecuredCacheDetailView(isMonitor, isSuperAdmin) { @@ -246,9 +273,11 @@ describe('RBAC Functionlity Tests', () => { cy.get('[data-cy=clearAllButton]').click(); cy.get('[data-cy=deleteButton]').click(); cy.wait(1500); //Waiting till the whole page is loaded - //Checking cache configuration page - cy.get('[data-cy=cacheConfigurationTab]').click(); - cy.contains('authorization').should('not.exist'); + if (isSuperAdmin) { + //Checking cache configuration page + cy.get('[data-cy=cacheConfigurationTab]').click(); + cy.contains('authorization').should('not.exist'); + } cy.get('[data-cy=manageIndexesLink]').click(); if (isSuperAdmin) { cy.get('[data-cy=clearIndexButton]').should('exist'); @@ -259,10 +288,11 @@ describe('RBAC Functionlity Tests', () => { cy.get('[data-cy=backButton]').click(); //Going to metrics page cy.get('[data-cy=cacheMetricsTab]').click(); - cy.get('[data-cy=data-distribution-chart]').should('exist'); if (isSuperAdmin) { + cy.get('[data-cy=data-distribution-chart]').should('exist'); cy.get('[data-cy=clearQueryMetricsButton]').should('exist'); } else { + cy.get('[data-cy=data-distribution-chart]').should('not.exist'); cy.get('[data-cy=clearQueryMetricsButton]').should('not.exist'); } @@ -314,7 +344,7 @@ describe('RBAC Functionlity Tests', () => { parseSpecialCharSequences: false }); cy.get('[data-cy=addButton]').click(); - cy.contains('Entry added to cache super-cache.'); + cy.contains('Entry added to cache a-rbac-test-cache.'); cy.get('[data-cy=actions-fordCar]').should('exist'); //Adding one more entry cy.get('[data-cy=addEntryButton]').click(); @@ -327,7 +357,7 @@ describe('RBAC Functionlity Tests', () => { parseSpecialCharSequences: false }); cy.get('[data-cy=addButton]').click(); - cy.contains('Entry added to cache super-cache.'); + cy.contains('Entry added to cache a-rbac-test-cache.'); cy.get('[data-cy=actions-kiaCar]').should('exist'); //Editing entry cy.get('[data-cy=actions-kiaCar] > button').click(); @@ -339,7 +369,7 @@ describe('RBAC Functionlity Tests', () => { parseSpecialCharSequences: false }); cy.get('[data-cy=addButton]').click(); - cy.contains('Entry updated in cache super-cache.'); + cy.contains('Entry updated in cache a-rbac-test-cache.'); cy.contains('2016'); //Deleting entry cy.get('[data-cy=actions-kiaCar] > button').click(); @@ -364,4 +394,23 @@ describe('RBAC Functionlity Tests', () => { cy.get('a[aria-label="nav-item-Tasks"]').click(); cy.contains('hello'); } + + function checkNoEntriesTabView(isSuperAdmin) { + // nobody sees manage metrics tab for default cache + cy.get('[data-cy=manageEntriesTab]').should('not.exist'); + cy.get('[data-cy=cacheMetricsTab]').should('exist'); + if (isSuperAdmin) { + cy.get('[data-cy=cacheConfigurationTab]').should('exist'); + // config tab is visible + cy.contains('JSON').should('exist'); + cy.get('[data-cy=cacheMetricsTab]').click(); + cy.contains('Data access').should('exist'); + } else { + // no config tab + cy.get('[data-cy=cacheConfigurationTab]').should('not.exist'); + // metrics tab is visible + cy.contains('Data access').should('exist'); + } + + } }); diff --git a/cypress/e2e/2_cache-detail-search.cy.js b/cypress/e2e/2_cache-detail-search.cy.js new file mode 100644 index 000000000..43fa6e720 --- /dev/null +++ b/cypress/e2e/2_cache-detail-search.cy.js @@ -0,0 +1,82 @@ +describe('Cache Detail Overview', () => { + beforeEach(() => { + cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/people'); + }); + + it('successfully searches by values', () => { + //Opening indexed-cache cache page. + cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/indexed-cache'); + + // Going back to cache entries page + cy.get('[data-cy=manageEntriesTab]').click(); + cy.get('[data-cy=queriesTab]').click(); + cy.get('#textSearchByQuery').click().type('from org.infinispan.Person where age>2'); + cy.get('button[aria-label=searchButton]').click(); + cy.contains('1 - 1 of 1'); + cy.contains('Elaia'); + + // Going back to cache entries page + cy.get('[data-cy=manageEntriesTab]').click(); + cy.get('[data-cy=queriesTab]').click(); + cy.get('#textSearchByQuery').click().clear().type("from org.infinispan.Person where name = 'Elaia'"); + cy.get('button[aria-label=searchButton]').click(); + cy.contains('1 - 1 of 1'); + cy.contains('Elaia'); + + // Going back to cache entries page + cy.get('[data-cy=manageEntriesTab]').click(); + cy.get('[data-cy=queriesTab]').click(); + + cy.get('#textSearchByQuery').click().clear().type('from org.infinispan.Person where age=2'); + cy.get('button[aria-label=searchButton]').click(); + cy.contains('Values not found.'); + + //Verify query metrics available + cy.get('[data-cy=viewQueryMetricsButton]').click(); + cy.contains('Query metrics'); + cy.contains('from org.infinispan.Person'); + cy.get('[data-cy=clearQueryMetricsButton]').click(); + cy.get('[data-cy=confirmButton]').click(); + cy.contains('from org.infinispan.Person').should('not.exist'); + + // Going back to cache entries page + cy.get('[data-cy=cacheEntriesTab]').click(); + cy.get('[data-cy="manageEntriesTab"]').click(); + cy.contains('key-9'); + }); + + it('successfully manages indexes', () => { + //Opening indexed-cache cache page. + cy.login(Cypress.env("username"), Cypress.env("password"), '/cache/indexed-cache'); + + cy.get("[data-cy=manageIndexesLink]").click(); + cy.contains("org.infinispan.Person"); + cy.contains("3 k"); + cy.get("[data-cy=backButton]").click(); + cy.contains("Elaia"); + + cy.get("[data-cy=manageIndexesLink]").click(); + cy.get("[data-cy=clearIndexButton]").click(); + cy.contains("Permanently clear index?"); + cy.get("[data-cy=cancelButton]").click(); + cy.contains("Permanently clear index?").should("not.exist"); + + cy.get("[data-cy=clearIndexButton]").click(); + cy.get("[data-cy=clearIndex]").click(); + cy.contains("Index of cache indexed-cache cleared."); + cy.contains("0"); + + cy.get("[data-cy=rebuildIndexButton]").click(); + cy.contains("Rebuild index?"); + cy.get("[data-cy=cancelReindexButton]").click(); + + cy.get("[data-cy=rebuildIndexButton]").click(); + cy.get("[data-cy=reindexButton]").click(); + cy.contains("1").should("not.exist"); + + cy.get("[data-cy=backButton]").click(); + cy.contains("Elaia"); + cy.get("[data-cy=manageIndexesLink]").click(); + cy.contains("3 k"); + }) +}); diff --git a/cypress/e2e/cache-detail.cy.js b/cypress/e2e/2_cache-detail.cy.js similarity index 89% rename from cypress/e2e/cache-detail.cy.js rename to cypress/e2e/2_cache-detail.cy.js index 3b0e5f9f8..e814b8a09 100644 --- a/cypress/e2e/cache-detail.cy.js +++ b/cypress/e2e/2_cache-detail.cy.js @@ -321,60 +321,7 @@ describe('Cache Detail Overview', () => { verifyCacheMetrics(0, 0, 0, 9, 10, 11, 19, 1, 0, 0); }); - it('successfully searches by values', () => { - //Opening indexed-cache cache page. - cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/indexed-cache'); - - //Verify metrics - verifyCacheMetrics(11, 11, 11, 0, 11, 11, 11, 0, 0, 0); - - // Going back to cache entries page - cy.get('[data-cy=cacheEntriesTab]').click(); - cy.get('[data-cy=queriesTab]').click(); - cy.get('#textSearchByQuery').click().type('from org.infinispan.Person where age>2'); - cy.get('button[aria-label=searchButton]').click(); - cy.contains('1 - 1 of 1'); - cy.contains('Elaia'); - - //Verify metrics - verifyCacheMetrics(11, 11, 11, 1, 11, 11, 12, 0, 0, 0); - - // Going back to cache entries page - cy.get('[data-cy=cacheEntriesTab]').click(); - cy.get('[data-cy=queriesTab]').click(); - - cy.get('#textSearchByQuery').click().clear().type("from org.infinispan.Person where name = 'Elaia'"); - cy.get('button[aria-label=searchButton]').click(); - cy.contains('1 - 1 of 1'); - cy.contains('Elaia'); - - //Verify metrics - verifyCacheMetrics(11, 11, 11, 2, 11, 11, 13, 0, 0, 0); - - // Going back to cache entries page - cy.get('[data-cy=cacheEntriesTab]').click(); - cy.get('[data-cy=queriesTab]').click(); - - cy.get('#textSearchByQuery').click().clear().type('from org.infinispan.Person where age=2'); - cy.get('button[aria-label=searchButton]').click(); - cy.contains('Values not found.'); - //Verify metrics - verifyCacheMetrics(11, 11, 11, 2, 11, 11, 13, 0, 0, 0); - - //Verify query metrics available - cy.contains('Query metrics'); - cy.contains('from org.infinispan.Person'); - cy.get('[data-cy=clearQueryMetricsButton]').click(); - cy.get('[data-cy=confirmButton]').click(); - cy.contains('from org.infinispan.Person').should('not.exist'); - - // Going back to cache entries page - cy.get('[data-cy=cacheEntriesTab]').click(); - cy.get('[data-cy="manageEntriesTab"]').click(); - cy.contains('key-9'); - }); - - it('successfully manages indexes', () => { + it('successfully manages indexes', () => { //Opening indexed-cache cache page. cy.login(Cypress.env("username"), Cypress.env("password"), '/cache/indexed-cache'); diff --git a/cypress/e2e/cache-metrics.cy.js b/cypress/e2e/2_cache-metrics.cy.js similarity index 92% rename from cypress/e2e/cache-metrics.cy.js rename to cypress/e2e/2_cache-metrics.cy.js index 1a50121da..3f3fa3dfc 100644 --- a/cypress/e2e/cache-metrics.cy.js +++ b/cypress/e2e/2_cache-metrics.cy.js @@ -17,14 +17,14 @@ describe('Cache Metrics Overview', () => { it('successfully checks cache metrics for heap memory', () => { cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/heap-test'); cy.contains('Metrics (Enabled)').click(); - cy.contains('Size of cache in heap memory'); + cy.contains('Size in heap memory'); cy.get('dt[aria-label="view-cache-metrics-heap"]').invoke('text').then(parseFloat).should('be.gt', -1); }); it('successfully checks cache metrics for off-heap memory', () => { cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/off-heap-test'); cy.contains('Metrics (Enabled)').click(); - cy.contains('Size of cache in off-heap memory'); + cy.contains('Size in off-heap memory'); cy.get('dt[aria-label="view-cache-metrics-off-heap"]').invoke('text').then(parseFloat).should('be.gt', -1); }); }); diff --git a/cypress/e2e/cache-templates.cy.js b/cypress/e2e/2_cache-templates.cy.js similarity index 100% rename from cypress/e2e/cache-templates.cy.js rename to cypress/e2e/2_cache-templates.cy.js diff --git a/cypress/e2e/cluster-membership.cy.js b/cypress/e2e/2_cluster-membership.cy.js similarity index 100% rename from cypress/e2e/cluster-membership.cy.js rename to cypress/e2e/2_cluster-membership.cy.js diff --git a/cypress/e2e/3_cache-crud-wizard.cy.js b/cypress/e2e/3_cache-crud-wizard.cy.js new file mode 100644 index 000000000..55adfb23a --- /dev/null +++ b/cypress/e2e/3_cache-crud-wizard.cy.js @@ -0,0 +1,237 @@ +describe('Cache Creation Wizard', () => { + beforeEach(() => { + cy.login(Cypress.env('username'), Cypress.env('password')); + }); + + it('successfully creates cache with all building options', () => { + //go to create cache page + cy.get('[data-cy=createCacheButton]').click(); + cy.get('#cache-name').click(); + cy.get('#cache-name').type('asuper-cache'); + cy.get('#configure').click(); + cy.get('[data-cy=wizardNextButton]').click(); + cy.get('#sync').click(); + cy.get('[data-cy=wizardNextButton]').click(); + + //Filling bounded cache properties + cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('boun'); + cy.get('#BOUNDED > button').click(); + cy.get('#size').click(); + cy.get('[data-cy=memorySizeInput]').clear().type('1'); + cy.get('#memorySizeUnit').click(); + cy.get('#KB').click(); + cy.get('#evictionStrategy').click(); + cy.get('#REMOVE').click(); + + //Filling indexed cache properties + cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('ind'); + cy.get('#INDEXED > button').click(); + cy.get('#persistent').click(); + cy.get('#auto').click(); + cy.get('#volatile').click(); + cy.get('#startupModeSelector').click(); + cy.get('#reindex').click(); + cy.get('[data-cy=indexSharding]').type(10); + cy.get('[data-cy=wizardNextButton]').should('be.disabled'); + cy.get('#entitiesSelector').click(); + cy.get('[id$="org.infinispan.Car"]').click(); + + //Filling auth cache properties + cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('auth'); + cy.get('#SECURED > button').click(); + cy.get('#roleSelector-select-multi-typeahead-typeahead').click().type('admin'); + cy.get('#admin > button').click(); + cy.get('#roleSelector-select-multi-typeahead-typeahead').click().type('application'); + cy.get('#application > button').click(); + cy.get('#roleSelector-select-multi-typeahead-typeahead').click().type('deployer'); + cy.get('#deployer > button').click(); + + //Filling persistant cache properties + cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('pers'); + cy.get('#PERSISTENCE > button').click(); + cy.get('[data-cy=passivationSwitch]').next().click(); + cy.get('[data-cy=connectionAttempts]').type(5); + cy.get('[data-cy=connectionInterval]').type(60); + cy.get('[data-cy=availabilityInterval]').type(5000); + cy.get('#persistentStorage').click(); + cy.get('#FileStore').click(); + + //Filling transactional cache properties + cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('trans'); + cy.get('#TRANSACTIONAL > button').click(); + cy.get('#non_xa').click(); + cy.get('#pessimistic').click(); + cy.get('[data-cy=wizardNextButton]').click(); + + cy.get('#storageSelector').click(); + cy.get('#HEAP').click(); + cy.get('[data-cy=concurencyLevel]').clear().type(40); + cy.get('[data-cy=lockTimeout]').clear().type(15); + cy.get('#striping').next().click(); + //Indexing tuning + cy.get('[data-cy=indexReaderExpand] button').click(); + cy.get('[data-cy=refreshInterval]').type(10); + cy.get('[data-cy=indexWriterExpand] button').click(); + cy.get('#low-level-trace').next().click(); + cy.get('[data-cy=commitInterval]').type(1001); + cy.get('[data-cy=ramBufferSize]').type(33); + cy.get('[data-cy=maxBufferedEntries]').type(33); + cy.get('[data-cy=threadPoolSize]').type(10); + cy.get('[data-cy=queueCount]').type(10); + cy.get('[data-cy=queueSize]').type(1050); + cy.get('[data-cy=indexMerge] button').click(); + cy.get('#calibrate-by-deletes').next().click(); + cy.get('[data-cy=factor]').type(10); + cy.get('[data-cy=maxEntries]').type(1000); + cy.get('[data-cy=minSize]').type(1000); + cy.get('[data-cy=maxSize]').type(10000); + cy.get('[data-cy=maxForcedSize]').type(10000); + //Transaction tuning + cy.get('#read-committed').click(); + cy.get('[data-cy=stopTimeout]').type(10000); + cy.get('[data-cy=completeTimeout]').type(50000); + cy.get('[data-cy=reaperInterval]').type(20000); + cy.get('[data-cy=wizardNextButton]').click(); + + //Verify before submitting and downloading file + cy.contains('asuper-cache'); + cy.get('[data-cy=downloadModal]').click(); + cy.get('[data-cy=downloadButton]').click(); + cy.wait(2000); + let downloadedFile = cy.readFile('./cypress/downloads/asuper-cache.json'); + downloadedFile.should('exist'); + downloadedFile.its('distributed-cache.mode').should('eq', 'SYNC'); + + cy.get('[data-cy=downloadModal]').click(); + cy.get('#XML').click(); + cy.get('[data-cy=downloadButton]').click(); + downloadedFile = cy.readFile('./cypress/downloads/asuper-cache.xml'); + downloadedFile.should('exist'); + + cy.get('[data-cy=downloadModal]').click(); + cy.get('#YAML').click(); + cy.get('[data-cy=downloadButton]').click(); + downloadedFile = cy.readFile('./cypress/downloads/asuper-cache.yaml'); + downloadedFile.should('exist'); + + cy.get('[data-cy=wizardNextButton]').click(); + + // Once the cache created, redirection to main page is done and the cache should be visible + cy.get('#cluster-manager-header').should('exist'); + cy.get('[data-cy=cacheManagerStatus]').should('exist'); + cy.get('[data-cy=rebalancingSwitch]').should('exist'); + cy.contains('asuper-cache'); + cy.get('[data-cy=feature-asuper-cache]').contains('Bounded'); + cy.get('[data-cy=feature-asuper-cache]').contains('Indexed'); + cy.get('[data-cy=feature-asuper-cache]').contains('Secured'); + cy.get('[data-cy=feature-asuper-cache]').contains('Persistent'); + cy.get('[data-cy=feature-asuper-cache]').contains('Transactional'); + deleteCache('asuper-cache'); + }); + + it('successfully creates with a template', () => { + const cacheName = 'aCache'; + //go to create cache page + cy.get('[data-cy=createCacheButton]').click(); + cy.get('#edit').click(); + //Checking that the Next button is disabled until the cache name is entered + cy.get('[data-cy=wizardNextButton]').should('be.disabled'); + + cy.get('#cache-name').click(); + cy.get('#cache-name').type(cacheName); + + cy.get('[data-cy=wizardNextButton]').click(); + + cy.get('#template-selector').click(); + cy.contains('e2e-test-template').parent().find('button').click(); + cy.get('[data-cy=wizardNextButton]').click(); + cy.contains('Cache ' + cacheName + ' successfully created with e2e-test-template.'); + // Once the cache created, redirection to main page is done and the cache should be visible + //Is redirected to Data Container page + cy.get('#cluster-manager-header').should('exist'); + cy.get('[data-cy=cacheManagerStatus]').should('exist'); + cy.get('[data-cy=rebalancingSwitch]').should('exist'); + cy.contains(cacheName); + deleteCache(cacheName); + }); + + it('successfully creates without a template a JSON config', () => { + //go to create cache page + cy.get('[data-cy=createCacheButton]').click(); + cy.get('#cache-name').click(); + cy.get('#cache-name').type('aSimpleCache'); + cy.get('#edit').click(); + cy.get('[data-cy=wizardNextButton]').click(); + cy.get('[data-cy=provideConfigArea] > button').click(); + + cy.get('.pf-v5-c-code-editor__code textarea:first').click({force: true}).focused().type( '{downArrow}' ) + .type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}") + .type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}") + .type("{shift}{end}").type("{del}{del}").type("{enter}{upArrow}").type('"distributed-cache": {{}"mode": "ASYNC", "statistics": true }{del}'); + + cy.get('[data-cy=wizardNextButton]').click(); + cy.contains('Cache aSimpleCache created with the provided configuration.'); + // Once the cache created, redirection to main page is done and the cache should be visible + cy.get('#cluster-manager-header').should('exist'); + cy.get('[data-cy=cacheManagerStatus]').should('exist'); + cy.get('[data-cy=rebalancingSwitch]').should('exist'); + cy.contains('aSimpleCache'); + deleteCache('aSimpleCache'); + }); + + it('successfully creates without a template a XML config', () => { + //go to create cache page + cy.get('[data-cy=createCacheButton]').click(); + cy.get('#cache-name').click(); + cy.get('#cache-name').type('aSimpleXmlCache'); + cy.get('#edit').click(); + cy.get('[data-cy=wizardNextButton]').click(); + cy.get('[data-cy=provideConfigArea] > button').click(); + + cy.get('.pf-v5-c-code-editor__code textarea:first').click({force: true}).focused().type( '{downArrow}' ) + .type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}") + .type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}") + .type("{shift}{end}").type("{del}{del}").type("{enter}{upArrow}") + .type( + '\ + \ + \ + ', + { parseSpecialCharSequences: false } + ).type("{del}{del}").type("{upArrow}{backspace}"); + cy.get('[data-cy=wizardNextButton]').click(); + cy.contains('Cache aSimpleXmlCache created with the provided configuration.'); + // Once the cache created, redirection to main page is done and the cache should be visible + cy.get('#cluster-manager-header').should('exist'); + cy.get('[data-cy=cacheManagerStatus]').should('exist'); + cy.get('[data-cy=rebalancingSwitch]').should('exist'); + cy.contains('aSimpleXmlCache'); + deleteCache('aSimpleXmlCache'); + }); + + function deleteCache(cacheName) { + cy.login(Cypress.env('username'), Cypress.env('password')); + cy.get(`[data-cy=actions-${cacheName}]`).click(); + cy.get('[aria-label=deleteCacheAction]').click(); + cy.get('#deleteCacheModal').should('exist'); + cy.contains('Permanently delete cache?'); + cy.get('#deleteCacheModal [aria-label=Close]').click(); //Closing modal with close button + cy.contains('Permanently delete cache?').should('not.exist'); + + cy.get(`[data-cy=actions-${cacheName}]`).click(); + cy.get('[aria-label=deleteCacheAction]').click(); + cy.contains('Permanently delete cache?'); + cy.get('[data-cy=cancelCacheDeleteButton]').click(); //Closing modal with Cancel button + cy.contains('Permanently delete cache?').should('not.exist'); + + cy.get(`[data-cy=actions-${cacheName}]`).click(); + cy.get('[aria-label=deleteCacheAction]').click(); + cy.get('#cache-to-delete').click(); + cy.get('#cache-to-delete').type(cacheName); + cy.get('[data-cy=deleteCacheButton]').click(); //Deleting cache aCache + + cy.contains(`Cache ${cacheName} deleted.`); + cy.get('.pf-v5-c-alert__action > .pf-v5-c-button').click(); //Closing alert popup. + cy.get('aCache').should('not.exist'); //Checking that deleted cache is not visible + } +}); diff --git a/cypress/e2e/3_client-connection.cy.js b/cypress/e2e/3_client-connection.cy.js new file mode 100644 index 000000000..09ba9ff2a --- /dev/null +++ b/cypress/e2e/3_client-connection.cy.js @@ -0,0 +1,16 @@ +describe('Client connection page', () => { + beforeEach(() => { + cy.login(Cypress.env('username'), Cypress.env('password'), '/connected-clients'); + }); + + it('successfully loads Client connections', () => { + cy.get('h1').should('contain', 'Connected clients'); + cy.contains('List and filter connected clients to this cluster').should('exist');; + cy.contains('Server node').should('exist'); + cy.contains('Principal').should('exist'); + cy.contains('Client library').should('exist'); + cy.contains('Client address').should('exist'); + cy.contains('Client version').should('exist'); + cy.contains('infinispan-4-e2e').should('exist'); + }); +}); diff --git a/cypress/e2e/counters.cy.js b/cypress/e2e/3_counters.cy.js similarity index 100% rename from cypress/e2e/counters.cy.js rename to cypress/e2e/3_counters.cy.js diff --git a/cypress/e2e/proto-schema.cy.js b/cypress/e2e/3_proto-schema.cy.js similarity index 84% rename from cypress/e2e/proto-schema.cy.js rename to cypress/e2e/3_proto-schema.cy.js index c286882f8..9b3e42959 100644 --- a/cypress/e2e/proto-schema.cy.js +++ b/cypress/e2e/3_proto-schema.cy.js @@ -50,16 +50,17 @@ describe('Proto Schema CRUD', () => { //Creating new schema cy.get('button[aria-label="create-schema-button"]').click(); - cy.get('#schema-name').click().type('aTestSchema'); + const schemaName = 'aTestSchema'; + cy.get('#schema-name').click().type(schemaName); cy.get('#schema').click().type('schemaValue'); cy.get('[data-cy="addSchemaButton"]').click(); - cy.contains('Schema aTestSchema created.'); + cy.contains('Schema ' + schemaName + ' created.'); cy.get('.pf-v5-c-alert__action > .pf-v5-c-button').click(); //Closing alert popup. - cy.contains('aTestSchema.proto'); + cy.contains(schemaName + '.proto'); //Updating existing schema - cy.contains('Schema aTestSchema.proto has errors'); - cy.get('[data-cy="actions-aTestSchema.proto"]>button').click(); + cy.contains('Schema ' + schemaName + '.proto has errors'); + cy.get('[data-cy="actions-' + schemaName + '.proto"]>button').click(); cy.get('[aria-label="editSchemaAction"]').click(); cy.contains('schemaValue'); cy.contains('Save'); @@ -67,13 +68,13 @@ describe('Proto Schema CRUD', () => { cy.get('[data-cy=schemaEditArea]').type('{selectall}', { timeout: 10000 }); cy.get('[data-cy=schemaEditArea]').type('schemaNewValue'); cy.get('button[aria-label="confirm-edit-schema-button"]').click(); - cy.contains('Schema aTestSchema.proto updated.'); + cy.contains('Schema ' + schemaName + '.proto updated.'); cy.get('.pf-v5-c-alert__action > .pf-v5-c-button').click(); //Closing alert popup. cy.contains('schemaNewValue'); //Updating existing schema with correct value - cy.contains('Schema aTestSchema.proto has errors'); - cy.get('[data-cy="actions-aTestSchema.proto"]>button').click(); + cy.contains('Schema ' + schemaName + '.proto has errors'); + cy.get('[data-cy="actions-' + schemaName + '.proto"]>button').click(); cy.get('[aria-label="editSchemaAction"]').click(); cy.get('[data-cy=schemaEditArea]').contains('schemaNewValue'); cy.get('[data-cy=schemaEditArea]').type('{selectall}', { timeout: 10000 }); @@ -82,24 +83,24 @@ describe('Proto Schema CRUD', () => { { parseSpecialCharSequences: false } ); cy.get('button[aria-label="confirm-edit-schema-button"]').click(); - cy.contains('Schema aTestSchema.proto updated.'); + cy.contains('Schema ' + schemaName +'.proto updated.'); cy.get('.pf-v5-c-alert__action > .pf-v5-c-button').click(); //Closing alert popup. - cy.get('[data-cy="aTestSchema.protoConfig"]').click(); + cy.get('[data-cy="' + schemaName + '.protoConfig"]').click(); cy.wait(1000) cy.contains('schemaNewValue').should('not.exist'); cy.contains('ExampleProto'); - cy.contains('Schema aTestSchema.proto has errors').should('not.exist'); + cy.contains('Schema ' + schemaName + '.proto has errors').should('not.exist'); //Deleting schema - cy.get('[data-cy="actions-aTestSchema.proto"]>button').click(); + cy.get('[data-cy="actions-' + schemaName + '.proto"]>button').click(); cy.get('[aria-label="deleteSchemaAction"]').click(); cy.contains('Delete schema?'); cy.get('button[aria-label="confirm-delete-schema-button"]').click(); - cy.contains('Schema aTestSchema.proto has been deleted.'); + cy.contains('Schema ' + schemaName + '.proto has been deleted.'); cy.get('.pf-v5-c-alert__action > .pf-v5-c-button').click(); //Closing alert popup. cy.contains('people.proto'); cy.get('button[aria-label="create-schema-button"]').scrollIntoView(); - cy.contains('aTestSchema.proto').should('not.exist'); + cy.contains(schemaName + '.proto').should('not.exist'); }); it('gives error if duplicate name is used while creating new schema', () => { diff --git a/cypress/e2e/cache-create-wizard-template.cy.js b/cypress/e2e/cache-create-wizard-template.cy.js deleted file mode 100644 index 797de0e99..000000000 --- a/cypress/e2e/cache-create-wizard-template.cy.js +++ /dev/null @@ -1,82 +0,0 @@ -describe('Cache Creation Wizard', () => { - beforeEach(() => { - cy.login(Cypress.env('username'), Cypress.env('password')); - }); - - it('successfully creates with a template', () => { - const cacheName = 'aCache'; - //go to create cache page - cy.get('[data-cy=createCacheButton]').click(); - cy.get('#edit').click(); - //Checking that the Next button is disabled until the cache name is entered - cy.get('[data-cy=wizardNextButton]').should('be.disabled'); - - cy.get('#cache-name').click(); - cy.get('#cache-name').type(cacheName); - - cy.get('[data-cy=wizardNextButton]').click(); - - cy.get('#template-selector').click(); - cy.contains('e2e-test-template').parent().find('button').click(); - cy.get('[data-cy=wizardNextButton]').click(); - cy.contains('Cache ' + cacheName + ' successfully created with e2e-test-template.'); - // Once the cache created, redirection to main page is done and the cache should be visible - //Is redirected to Data Container page - cy.get('#cluster-manager-header').should('exist'); - cy.get('[data-cy=cacheManagerStatus]').should('exist'); - cy.get('[data-cy=rebalancingSwitch]').should('exist'); - cy.contains(cacheName); - }); - - it('successfully creates without a template a JSON config', () => { - //go to create cache page - cy.get('[data-cy=createCacheButton]').click(); - cy.get('#cache-name').click(); - cy.get('#cache-name').type('aSimpleCache'); - cy.get('#edit').click(); - cy.get('[data-cy=wizardNextButton]').click(); - cy.get('[data-cy=provideConfigArea] > button').click(); - - cy.get('.pf-v5-c-code-editor__code textarea:first').click({force: true}).focused().type( '{downArrow}' ) - .type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}") - .type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}") - .type("{shift}{end}").type("{del}{del}").type("{enter}{upArrow}").type('"distributed-cache": {{}"mode": "ASYNC", "statistics": true }{del}'); - - cy.get('[data-cy=wizardNextButton]').click(); - cy.contains('Cache aSimpleCache created with the provided configuration.'); - // Once the cache created, redirection to main page is done and the cache should be visible - cy.get('#cluster-manager-header').should('exist'); - cy.get('[data-cy=cacheManagerStatus]').should('exist'); - cy.get('[data-cy=rebalancingSwitch]').should('exist'); - cy.contains('aSimpleCache'); - }); - - it('successfully creates without a template a XML config', () => { - //go to create cache page - cy.get('[data-cy=createCacheButton]').click(); - cy.get('#cache-name').click(); - cy.get('#cache-name').type('aSimpleXmlCache'); - cy.get('#edit').click(); - cy.get('[data-cy=wizardNextButton]').click(); - cy.get('[data-cy=provideConfigArea] > button').click(); - - cy.get('.pf-v5-c-code-editor__code textarea:first').click({force: true}).focused().type( '{downArrow}' ) - .type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}") - .type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}").type("{shift}{end}").type("{del}{del}") - .type("{shift}{end}").type("{del}{del}").type("{enter}{upArrow}") - .type( - '\ - \ - \ - ', - { parseSpecialCharSequences: false } - ).type("{del}{del}").type("{upArrow}{backspace}"); - cy.get('[data-cy=wizardNextButton]').click(); - cy.contains('Cache aSimpleXmlCache created with the provided configuration.'); - // Once the cache created, redirection to main page is done and the cache should be visible - cy.get('#cluster-manager-header').should('exist'); - cy.get('[data-cy=cacheManagerStatus]').should('exist'); - cy.get('[data-cy=rebalancingSwitch]').should('exist'); - cy.contains('aSimpleXmlCache'); - }); -}); diff --git a/cypress/e2e/cache-create-wizard.cy.js b/cypress/e2e/cache-create-wizard.cy.js deleted file mode 100644 index b6b32430d..000000000 --- a/cypress/e2e/cache-create-wizard.cy.js +++ /dev/null @@ -1,135 +0,0 @@ -function createRandomCacheName() { - return (Math.random() + 1).toString(36).substring(3); -} - -describe('Cache Creation Wizard', () => { - beforeEach(() => { - cy.login(Cypress.env('username'), Cypress.env('password')); - }); - - it('successfully creates cache with all building options', () => { - //go to create cache page - cy.get('[data-cy=createCacheButton]').click(); - cy.get('#cache-name').click(); - cy.get('#cache-name').type('super-cache'); - cy.get('#configure').click(); - cy.get('[data-cy=wizardNextButton]').click(); - cy.get('#sync').click(); - cy.get('[data-cy=wizardNextButton]').click(); - - //Filling bounded cache properties - cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('boun'); - cy.get('#BOUNDED > button').click(); - cy.get('#size').click(); - cy.get('[data-cy=memorySizeInput]').clear().type('1'); - cy.get('#memorySizeUnit').click(); - cy.get('#KB').click(); - cy.get('#evictionStrategy').click(); - cy.get('#REMOVE').click(); - - //Filling indexed cache properties - cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('ind'); - cy.get('#INDEXED > button').click(); - cy.get('#persistent').click(); - cy.get('#auto').click(); - cy.get('#volatile').click(); - cy.get('#startupModeSelector').click(); - cy.get('#reindex').click(); - cy.get('[data-cy=indexSharding]').type(10); - cy.get('[data-cy=wizardNextButton]').should('be.disabled'); - cy.get('#entitiesSelector').click(); - cy.get('[id$="org.infinispan.Car"]').click(); - - //Filling auth cache properties - cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('auth'); - cy.get('#SECURED > button').click(); - cy.get('#roleSelector-select-multi-typeahead-typeahead').click().type('admin'); - cy.get('#admin > button').click(); - cy.get('#roleSelector-select-multi-typeahead-typeahead').click().type('application'); - cy.get('#application > button').click(); - cy.get('#roleSelector-select-multi-typeahead-typeahead').click().type('deployer'); - cy.get('#deployer > button').click(); - - //Filling persistant cache properties - cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('pers'); - cy.get('#PERSISTENCE > button').click(); - cy.get('[data-cy=passivationSwitch]').next().click(); - cy.get('[data-cy=connectionAttempts]').type(5); - cy.get('[data-cy=connectionInterval]').type(60); - cy.get('[data-cy=availabilityInterval]').type(5000); - cy.get('#persistentStorage').click(); - cy.get('#FileStore').click(); - - //Filling transactional cache properties - cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('trans'); - cy.get('#TRANSACTIONAL > button').click(); - cy.get('#non_xa').click(); - cy.get('#pessimistic').click(); - cy.get('[data-cy=wizardNextButton]').click(); - - cy.get('#storageSelector').click(); - cy.get('#HEAP').click(); - cy.get('[data-cy=concurencyLevel]').clear().type(40); - cy.get('[data-cy=lockTimeout]').clear().type(15); - cy.get('#striping').next().click(); - //Indexing tuning - cy.get('[data-cy=indexReaderExpand] button').click(); - cy.get('[data-cy=refreshInterval]').type(10); - cy.get('[data-cy=indexWriterExpand] button').click(); - cy.get('#low-level-trace').next().click(); - cy.get('[data-cy=commitInterval]').type(1001); - cy.get('[data-cy=ramBufferSize]').type(33); - cy.get('[data-cy=maxBufferedEntries]').type(33); - cy.get('[data-cy=threadPoolSize]').type(10); - cy.get('[data-cy=queueCount]').type(10); - cy.get('[data-cy=queueSize]').type(1050); - cy.get('[data-cy=indexMerge] button').click(); - cy.get('#calibrate-by-deletes').next().click(); - cy.get('[data-cy=factor]').type(10); - cy.get('[data-cy=maxEntries]').type(1000); - cy.get('[data-cy=minSize]').type(1000); - cy.get('[data-cy=maxSize]').type(10000); - cy.get('[data-cy=maxForcedSize]').type(10000); - //Transaction tuning - cy.get('#read-committed').click(); - cy.get('[data-cy=stopTimeout]').type(10000); - cy.get('[data-cy=completeTimeout]').type(50000); - cy.get('[data-cy=reaperInterval]').type(20000); - cy.get('[data-cy=wizardNextButton]').click(); - - //Verify before submitting and downloading file - cy.contains('super-cache'); - cy.get('[data-cy=downloadModal]').click(); - cy.get('[data-cy=downloadButton]').click(); - cy.wait(2000); - var downloadedFile = cy.readFile('./cypress/downloads/super-cache.json'); - downloadedFile.should('exist'); - downloadedFile.its('distributed-cache.mode').should('eq', 'SYNC'); - - cy.get('[data-cy=downloadModal]').click(); - cy.get('#XML').click(); - cy.get('[data-cy=downloadButton]').click(); - downloadedFile = cy.readFile('./cypress/downloads/super-cache.xml'); - downloadedFile.should('exist'); - - cy.get('[data-cy=downloadModal]').click(); - cy.get('#YAML').click(); - cy.get('[data-cy=downloadButton]').click(); - downloadedFile = cy.readFile('./cypress/downloads/super-cache.yaml'); - downloadedFile.should('exist'); - - cy.get('[data-cy=wizardNextButton]').click(); - - // Once the cache created, redirection to main page is done and the cache should be visible - cy.get('#cluster-manager-header').should('exist'); - cy.get('[data-cy=cacheManagerStatus]').should('exist'); - cy.get('[data-cy=rebalancingSwitch]').should('exist'); - cy.get('[data-action=next]').first().click(); - cy.contains('super-cache'); - cy.get('[data-cy=feature-super-cache]').contains('Bounded'); - cy.get('[data-cy=feature-super-cache]').contains('Indexed'); - cy.get('[data-cy=feature-super-cache]').contains('Secured'); - cy.get('[data-cy=feature-super-cache]').contains('Persistent'); - cy.get('[data-cy=feature-super-cache]').contains('Transactional'); - }); -}); diff --git a/package-lock.json b/package-lock.json index 81e4a9861..62daac136 100644 --- a/package-lock.json +++ b/package-lock.json @@ -77,6 +77,7 @@ "tslib": "^2.6.1", "typescript": "^5.1.6", "url-loader": "^4.1.1", + "uuid": "^9.0.1", "webpack": "^5.88.2", "webpack-bundle-analyzer": "^4.9.0", "webpack-cli": "^5.1.4", @@ -817,6 +818,15 @@ "node": ">= 6" } }, + "node_modules/@cypress/request/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@cypress/xvfb": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/@cypress/xvfb/-/xvfb-1.2.4.tgz", @@ -13147,6 +13157,15 @@ "websocket-driver": "^0.7.4" } }, + "node_modules/sockjs/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -14606,10 +14625,14 @@ } }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "bin": { "uuid": "dist/bin/uuid" } diff --git a/package.json b/package.json index 860eeb2af..67e3abc95 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "tslib": "^2.6.1", "typescript": "^5.1.6", "url-loader": "^4.1.1", + "uuid": "^9.0.1", "webpack": "^5.88.2", "webpack-bundle-analyzer": "^4.9.0", "webpack-cli": "^5.1.4", diff --git a/run-server-for-e2e-container.sh b/run-server-for-e2e-container.sh new file mode 100755 index 000000000..fde80ba14 --- /dev/null +++ b/run-server-for-e2e-container.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -e + +ABSOLUTE_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +echo ${ABSOLUTE_PATH} +docker pull quay.io/infinispan-test/server:main +docker run -d -p 11222:11222 -v ${ABSOLUTE_PATH}/scripts/identities.batch:/user-config/identities.batch -v ${ABSOLUTE_PATH}/dist:/opt/infinispan/static/console -v ${ABSOLUTE_PATH}/scripts/infinispan-basic-auth.xml:/opt/infinispan/server/conf/infinispan.xml -e JAVA_OPTIONS="-Xms1024m -Xmx3072m -XX:MetaspaceSize=1024m -XX:MaxMetaspaceSize=2048m" -e IDENTITIES_BATCH="/user-config/identities.batch" quay.io/infinispan-test/server:main --node-name=infinispan-4-e2e +docker exec $(docker ps -q -l) /opt/infinispan/bin/cli.sh install org.openjdk.nashorn:nashorn-core:15.4 +docker exec $(docker ps -q -l) /opt/infinispan/bin/cli.sh install org.ow2.asm:asm:9.4 +docker exec $(docker ps -q -l) /opt/infinispan/bin/cli.sh install org.ow2.asm:asm-commons:9.4 +docker exec $(docker ps -q -l) /opt/infinispan/bin/cli.sh install org.ow2.asm:asm-tree:9.4 +docker exec $(docker ps -q -l) /opt/infinispan/bin/cli.sh install org.ow2.asm:asm-util:9.4 + +docker restart $(docker ps -q -l) + +sleep 20 +cd data; bash ./create-data.sh admin password diff --git a/run-server-for-e2e.sh b/run-server-for-e2e.sh deleted file mode 100755 index 206d44596..000000000 --- a/run-server-for-e2e.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [[ $1 = "--ci" ]]; then - echo "Launch script finished" -else - trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT -fi - -#If running on the existing server please provide the Path with this property. -EXISTING_SERVER_PATH="${EXISTING_SERVER_PATH}" -#Base directory where the server should be downloaded -BASE_DIR="server" -#The version of the server is either set as an environment variable or is the latest dev version -SERVER_VERSION="${SERVER_VERSION:-"15.0.0.Dev03"}" -#Root path from there the infinispan server should be downloaded -ZIP_ROOT="http://downloads.jboss.org/infinispan" -#If this environment variable is provided then it is used for downloading the server; -SERVER_DOWNLOAD_URL="${SERVER_DOWNLOAD_URL}" -#The name of the zip file; -ZIP_NAME="${ZIP_NAME:-"infinispan-server-$SERVER_VERSION.zip"}" -#The name of directory where the server should be extracted; -SERVER_UNZIP_DIR="server-unzipped" -#Path to the extracted server; -SERVER_HOME=${BASE_DIR}/${SERVER_UNZIP_DIR} - -CONF_DIR_TO_COPY_FROM="scripts/" -DATA_DIR="data/" -IS_SSL_PROCESSED=0 -#The working directory - the server is copied to this directory and later changes are done to this dir; -SERVER_DIR="infinispan-server" -#CLI command for getting the cluster size -CLUSTER_SIZE_MAIN="$SERVER_HOME/bin/cli.sh -c localhost:11322 -f batch " - -USER_NAME="admin" -PASSWORD="password" - -MONITOR_USER_NAME="monitor" -OBSERVER_USER_NAME="observer" -APPLICATION_USER_NAME="application" -DEPLOYER_USER_NAME="deployer" - -#Function prepares the server directory, i.e. downloads, extracts, copies to working directory and makes changes to configuration; -function prepareServerDir() -{ - local isCi=$1 - local confPath=$2 - local dirName=${3} - - cd ${BASE_DIR} - if [ -n "${EXISTING_SERVER_PATH}" ]; then - mkdir ${SERVER_UNZIP_DIR} - cp -r ${EXISTING_SERVER_PATH} $SERVER_UNZIP_DIR - else - if [ ! -f ${ZIP_NAME} ]; then - if [ -n "$SERVER_DOWNLOAD_URL" ]; then - wget "${SERVER_DOWNLOAD_URL}" - else - wget "$ZIP_ROOT/$SERVER_VERSION/$ZIP_NAME"; - fi - fi - - unzip -d $SERVER_UNZIP_DIR $ZIP_NAME - fi - - cd .. - - if [[ -z "${SERVER_TMP}" ]]; then - SERVER_TMP=server/${SERVER_DIR} - mkdir ${SERVER_TMP} 2>/dev/null - echo "Created temporary directory: $SERVER_TMP" - - cp -r ${SERVER_HOME}/*/* $SERVER_TMP - echo "Server copied to temporary directory." - fi - - cp -r ${SERVER_HOME}/*/server ${SERVER_TMP}/${dirName} - - cp "${CONF_DIR_TO_COPY_FROM}/${confPath}" ${SERVER_TMP}/${dirName}/conf - echo "Infinispan configuration file ${confPath} copied to server ${dirName}." - - export SERVER_TMP=${SERVER_TMP} -} - -#Starts the server; -function startServer() -{ - local isCi=$1 - local confPath=$2 - local port=${3} - local nodeName=${4} - local jvmParam=${5} - - prepareServerDir "${isCi}" ${confPath} ${nodeName} - - if [[ ! -z ${port} ]]; then - portStr="-p ${port}" - fi - - - ${SERVER_TMP}/bin/cli.sh user create ${USER_NAME} -p ${PASSWORD} -s ${nodeName} -g admin - ${SERVER_TMP}/bin/cli.sh user create ${MONITOR_USER_NAME} -p ${PASSWORD} -s ${nodeName} -g monitor - ${SERVER_TMP}/bin/cli.sh user create ${OBSERVER_USER_NAME} -p ${PASSWORD} -s ${nodeName} -g observer - ${SERVER_TMP}/bin/cli.sh user create ${APPLICATION_USER_NAME} -p ${PASSWORD} -s ${nodeName} -g application - ${SERVER_TMP}/bin/cli.sh user create ${DEPLOYER_USER_NAME} -p ${PASSWORD} -s ${nodeName} -g deployer - - #Installing nashorn engine before server startup - ${SERVER_TMP}/bin/cli.sh install org.openjdk.nashorn:nashorn-core:15.4 --server-root=infinispan-4-e2e - ${SERVER_TMP}/bin/cli.sh install org.ow2.asm:asm:9.4 --server-root=infinispan-4-e2e - ${SERVER_TMP}/bin/cli.sh install org.ow2.asm:asm-commons:9.4 --server-root=infinispan-4-e2e - ${SERVER_TMP}/bin/cli.sh install org.ow2.asm:asm-tree:9.4 --server-root=infinispan-4-e2e - ${SERVER_TMP}/bin/cli.sh install org.ow2.asm:asm-util:9.4 --server-root=infinispan-4-e2e - - if [[ ${isCi} = "--ci" ]]; then - nohup $SERVER_TMP/bin/server.sh -Djavax.net.debug -Dorg.infinispan.openssl=false -c ${confPath} -s ${SERVER_TMP}/${nodeName} ${portStr:-""} --node-name=${nodeName} ${jvmParam:-} & - else - ${SERVER_TMP}/bin/server.sh -Djavax.net.debug -Dorg.infinispan.openssl=false -c ${confPath} -s ${SERVER_TMP}/${nodeName} ${portStr:-} --node-name=${nodeName} ${jvmParam:-} & - fi - - #Creating data in the server - sleep 10 - cd $DATA_DIR/ - ./create-data.sh ${USER_NAME} ${PASSWORD} -} - -#deleting the testable server directory -rm -drf server/${SERVER_DIR} -rm -drf server/${SERVER_UNZIP_DIR} - -export JAVA_OPTS="-Xms512m -Xmx1024m -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=512m" - -startServer "$1" infinispan-basic-auth.xml 11222 infinispan-4-e2e -echo "Infinispan Server for E2E tests has started." - - -if [[ $1 = "--ci" ]]; then - echo "Launch script finished" -else - # Wait until script stopped - while : - do - sleep 5 - done -fi diff --git a/scripts/infinispan-basic-auth.xml b/scripts/infinispan-basic-auth.xml index 98012aba7..b0d1de570 100644 --- a/scripts/infinispan-basic-auth.xml +++ b/scripts/infinispan-basic-auth.xml @@ -32,6 +32,24 @@ + + + + + + + + org.infinispan.Car + + + + + + + + + + diff --git a/src/__tests__/services/cacheConfigUtils.test.ts b/src/__tests__/services/cacheConfigUtils.test.ts index 16d277c76..1e486d5c8 100644 --- a/src/__tests__/services/cacheConfigUtils.test.ts +++ b/src/__tests__/services/cacheConfigUtils.test.ts @@ -1,20 +1,43 @@ -import { CacheConfigUtils, Distributed, Invalidated, Local, Replicated } from '@services/cacheConfigUtils'; +import { + CacheConfigUtils, + DIST_ASYNC, + DIST_SYNC, + Distributed, + Invalidated, + INVALIDATION_ASYNC, + INVALIDATION_SYNC, + LOCAL, + Local, + REPL_ASYNC, + REPL_SYNC, + Replicated +} from '@services/cacheConfigUtils'; import { ContentType, EncodingType } from '@services/infinispanRefData'; describe('Cache Config Utils tests', () => { test('cache topology', () => { - let distributed = '{\n' + ' "distributed-cache": {\n' + ' }\n' + '}'; - - expect(CacheConfigUtils.mapCacheType(JSON.parse(distributed))).toBe('Distributed'); - - let replicated = '{\n' + ' "replicated-cache": {\n' + ' }\n' + '}'; - - expect(CacheConfigUtils.mapCacheType(JSON.parse(replicated))).toBe('Replicated'); + expect(CacheConfigUtils.mapCacheType(DIST_SYNC)).toBe('Distributed'); + expect(CacheConfigUtils.mapCacheType(DIST_ASYNC)).toBe('Distributed'); + expect(CacheConfigUtils.mapCacheType(REPL_SYNC)).toBe('Replicated'); + expect(CacheConfigUtils.mapCacheType(REPL_ASYNC)).toBe('Replicated'); + expect(CacheConfigUtils.mapCacheType(LOCAL)).toBe('Local'); + expect(CacheConfigUtils.mapCacheType(INVALIDATION_ASYNC)).toBe('Invalidated'); + expect(CacheConfigUtils.mapCacheType(INVALIDATION_SYNC)).toBe('Invalidated'); expect(CacheConfigUtils.mapCacheType(Distributed)).toBe('Distributed'); expect(CacheConfigUtils.mapCacheType(Replicated)).toBe('Replicated'); - expect(CacheConfigUtils.mapCacheType(Local)).toBe('Local'); expect(CacheConfigUtils.mapCacheType(Invalidated)).toBe('Invalidated'); + expect(CacheConfigUtils.mapCacheType(Local)).toBe('Local'); + }); + + test('cache sync or async', () => { + expect(CacheConfigUtils.isAsync(DIST_SYNC)).toBe(false); + expect(CacheConfigUtils.isAsync(DIST_ASYNC)).toBe(true); + expect(CacheConfigUtils.isAsync(REPL_SYNC)).toBe(false); + expect(CacheConfigUtils.isAsync(REPL_ASYNC)).toBe(true); + expect(CacheConfigUtils.isAsync(LOCAL)).toBe(false); + expect(CacheConfigUtils.isAsync(INVALIDATION_ASYNC)).toBe(true); + expect(CacheConfigUtils.isAsync(INVALIDATION_SYNC)).toBe(false); }); test('editable', () => { diff --git a/src/__tests__/views/CacheConfiguration.test.tsx b/src/__tests__/views/CacheConfiguration.test.tsx index da9ead6c1..d0af515ea 100644 --- a/src/__tests__/views/CacheConfiguration.test.tsx +++ b/src/__tests__/views/CacheConfiguration.test.tsx @@ -49,7 +49,6 @@ describe('Configuration Page', () => { configuration: yamlConfig }; }); - renderWithRouter(); expect(screen.getByText('JSON')).toBeInTheDocument(); expect(screen.getByText('XML')).toBeInTheDocument(); diff --git a/src/app/AppLayout/AppLayout.tsx b/src/app/AppLayout/AppLayout.tsx index 24a2f9079..fe71a9413 100644 --- a/src/app/AppLayout/AppLayout.tsx +++ b/src/app/AppLayout/AppLayout.tsx @@ -36,7 +36,7 @@ import { } from '@patternfly/react-core/deprecated'; import icon from '!!url-loader!@app/assets/images/brand.svg'; import { Link, NavLink, Redirect } from 'react-router-dom'; -import { routes } from '@app/routes'; +import { IAppRoute, routes } from '@app/routes'; import { APIAlertProvider } from '@app/providers/APIAlertProvider'; import { ActionResponseAlert } from '@app/Common/ActionResponseAlert'; import { useHistory } from 'react-router'; @@ -131,8 +131,8 @@ const AppLayout: React.FunctionComponent = ({ init, children }) => { return ( {connectedUser.name} - Close the browser or open an incognito window to log again.}> - + {t('layout.close-browser-message')}}> + @@ -142,14 +142,14 @@ const AppLayout: React.FunctionComponent = ({ init, children }) => { const helpDropdownItems = [ window.open('https://infinispan.org/documentation/', '_blank')} + onClick={() => window.open(t('brandname.documentation-link'), '_blank')} key="documentation" icon={} > - Documentation + {t('layout.documentation-name')} , setIsAboutOpen(!isAboutOpen)} key="about" component="button"> - About + {t('layout.about-name')} ]; @@ -204,13 +204,20 @@ const AppLayout: React.FunctionComponent = ({ init, children }) => { // The menu for non admin users const filteredRoutes = routes.filter((route) => !route.readonlyUser || (!create && route.readonlyUser)); + const displayNavMenu = (route: IAppRoute): boolean => { + return ( + route.menu == true && + route.label !== undefined && + (!route.admin || (route.admin && ConsoleServices.security().hasConsoleACL(ConsoleACL.ADMIN, connectedUser))) + ); + }; + const Navigation = (