Skip to content

Commit

Permalink
XSite Repl test environment is configured and new tests are added.
Browse files Browse the repository at this point in the history
  • Loading branch information
andyuk1986 committed May 25, 2023
1 parent 9015082 commit 0472967
Show file tree
Hide file tree
Showing 15 changed files with 518 additions and 22 deletions.
4 changes: 4 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ export default defineConfig({
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:11222/console/',
experimentalSessionAndOrigin: true,
excludeSpecPattern: [
'cypress/e2e/xsite.cy.js'
]
},
})
267 changes: 267 additions & 0 deletions cypress/e2e/xsite.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
describe('XSite Config Tests', () => {
beforeEach(() => {
cy.login(Cypress.env('username'), Cypress.env('password'));
});

it('successfully creates cache with backup', () => {
cy.contains("Site: LON");

//Going to create cache page
cy.get('[data-cy=createCacheButton]').click();
cy.get('#cache-name').click();
cy.get('#cache-name').type('xsite-cache');
cy.get('#configure').click();
cy.get('[data-cy=wizardNextButton]').click();
cy.get('#sync').click();
cy.get('[data-cy=wizardNextButton]').click();

//Filling backup cache properties
cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('backup');
cy.get('#BACKUPS > button').click();
cy.contains("Backups for LON");
cy.get('button#backup-selector').click();
cy.get('#NYC').click();
cy.get("#sync-0").click();
cy.get("#backupfor").click({force: true});
cy.get("[data-cy=remote-cache-input]").type("xsite-backup");
cy.get('#remote-site-selector').click();
cy.get("#NYC").click();
cy.get('[data-cy=wizardNextButton]').click();
cy.contains("Adjust settings for cache backups");
//Filling backup cache tuning properties
cy.get("[data-cy=merge-policy-input]").type("DEFAULT");
cy.get("[data-cy=max-cleanup-delay-input]").type("3000");
cy.get("[data-cy=tombstone-map-size-input]").type("5120");
cy.get("[id^=form-field-group-toggle]").click();
cy.get("#twoPhaseCommit").click({force: true});
cy.get("[id^=failurePolicySelector]").click();
cy.get("[data-cy=failurePolicyTimeoutInput]").type(10000);
cy.get('[data-cy="afterFailuresInput"]').type(10);
cy.get('[data-cy="minWaitInput"]').type(50000);
cy.get('[data-cy="manual-radio"]').click();
cy.get('[data-cy="chunckSizeInput"]').type(256);
cy.get('[data-cy="stateTransferTimeoutInput"]').type(60000);
cy.get('[data-cy="maxRetriesInput"]').type(25);
cy.get('[data-cy="waitTimeInput"]').type(1000);
cy.get('[data-cy=wizardNextButton]').click();
cy.get('[data-cy=wizardNextButton]').click(); //Saving the cache
cy.get('[data-cy="detailButton-xsite-cache"]').click();
cy.contains('The cache is empty');
cy.get("[data-cy=manageBackupsLink]").click();
cy.contains('Take offline');
cy.origin('http://localhost:31222/console/', () => {
cy.visit("/", {
headers: {
'Accept-Encoding': 'gzip, deflate, br'
},
auth: {
username: Cypress.env('username'),
password: Cypress.env('password')
}
});
cy.contains("Site: NYC");
cy.contains("xsiteCache");
//Going to create cache page
cy.get('[data-cy=createCacheButton]').click();
cy.get('#cache-name').click();
cy.get('#cache-name').type('xsite-backup');
cy.get('#configure').click();
cy.get('[data-cy=wizardNextButton]').click();
cy.get('#async').click();
cy.get('[data-cy=wizardNextButton]').click();

//Filling backup cache properties
cy.get('#featuresSelect-select-multi-typeahead-typeahead').click().type('backup');
cy.get('#BACKUPS > button').click();
cy.contains("Backups for NYC");
cy.get('button#backup-selector').click();
cy.get('#LON').click();
cy.get("#async-0").click();
cy.get('[data-cy=wizardNextButton]').click();
cy.get('[data-cy=wizardNextButton]').click();
cy.get('[data-cy=wizardNextButton]').click(); //Saving cache
cy.get('[data-cy="detailButton-xsite-backup"]').click();
cy.contains("Backups");
cy.get("[data-cy=manageBackupsLink]").click();
cy.contains("Backups management");
cy.contains("LON");
cy.contains("Take offline");
//Going back to cache details page
cy.get("[data-cy=backToCacheDetailsButton]").click();

//Adding new entry
cy.get('[data-cy=addEntryButton]').click();
cy.get('#key-entry').click().type('key1');
cy.get('#value-entry').click().type('value1');
cy.get('[data-cy=addButton]').click();
cy.contains('Entry added to cache xsite-backup.');
cy.contains('key1');
cy.contains('value1');
})
});

it('successfully shows the site name on data container page', () => {
cy.contains("Site: LON");
cy.contains("xsiteCache");
cy.contains("xsite-cache");

//Verifying that entries entered in previous test were successfully synced
cy.get('[data-cy="detailButton-xsite-cache"]').click();
cy.contains('key1');
cy.contains('value1');

cy.get("#nav-toggle").click();
cy.contains("Cluster Membership").click();
cy.contains("2 members in use");

cy.origin('http://localhost:31222/console/', () => {
cy.visit("/", {
headers: {
'Accept-Encoding': 'gzip, deflate, br'
},
auth: {
username: Cypress.env('username'),
password: Cypress.env('password')
}
});
cy.contains("Site: NYC");
cy.contains("xsiteCache");
cy.get("#nav-toggle").click();
cy.contains("Cluster Membership").click();
cy.contains("2 members in use");
})
});

it('successfully views the Manage Backup pages.', () => {
cy.contains("Site: LON");
cy.contains("xsiteCache").click();
cy.contains("Backups");
cy.contains('1 - 5 of 5');
cy.get("[data-cy=manageBackupsLink]").click();
cy.contains("Backups management");
cy.contains("NYC");
cy.contains("Take offline");
cy.get("[data-cy=NYC-startTransfer]").should("exist");

cy.origin('http://localhost:31222/console/', () => {
cy.visit("/", {
headers: {
'Accept-Encoding': 'gzip, deflate, br'
},
auth: {
username: Cypress.env('username'),
password: Cypress.env('password')
}
});
cy.contains("Site: NYC");
cy.contains("xsiteCache").click();
cy.contains('1 - 5 of 5');
cy.contains("Backups").should('not.exist');
cy.get("[data-cy=manageBackupsLink]").should('not.exist');
})
});

it('successfully takes offline the backup, adds/deletes/updates data and verifies that backup doesn\'t contain all changes', () => {
cy.contains("xsiteCache").click();
//Going to manage Backups page and taking the backup site offline
cy.get("[data-cy=manageBackupsLink]").click();
cy.contains("Take offline");
cy.get("#NYC-switch").click({force: true});
cy.contains("Operation take offline on site NYC has started.");
cy.contains("Bring online");

//Going back to cache details page
cy.get("[data-cy=backToCacheDetailsButton]").click();

//Editing entry
cy.get('[data-cy=actions-key3]').click();
cy.get("[data-cy=editEntryAction]").click();
cy.get("#value-entry").type("1");
cy.get("[data-cy=addButton]").click();
cy.contains("value31");

//Deleting entry
cy.get("[data-cy=actions-key5]").click();
cy.get("[data-cy=deleteEntryAction]").click();
cy.get("[data-cy=deleteEntryButton]").click();

//Adding new entry
cy.get('[data-cy=addEntryButton]').click();
cy.get('#key-entry').click().type('stringKey');
cy.get('#value-entry').click().type('stringValue');
cy.get('[data-cy=addButton]').click();
cy.contains('Entry added to cache xsiteCache.');
cy.get('.pf-c-alert__action > .pf-c-button').click(); //Closing alert popup.
cy.contains('stringKey');
cy.contains('stringValue');

//Verifying that as the backup site is taken offline neither of the changes is visible on the backup site.
cy.origin('http://localhost:31222/console/', () => {
cy.visit("/", {
headers: {
'Accept-Encoding': 'gzip, deflate, br'
},
auth: {
username: Cypress.env('username'),
password: Cypress.env('password')
}
});
cy.contains("Site: NYC");
cy.contains("xsiteCache").click();
cy.contains('1 - 5 of 5');
cy.contains("stringKey").should("not.exist");
cy.contains("key5");
cy.contains("value31").should("not.exist");
});
});

it('successfully brings online the backup, performs the state transfer and verifies that changes appeared on backup site', () => {
cy.contains("xsiteCache").click();
//Going to manage Backups page and bringing the backup site online
cy.get("[data-cy=manageBackupsLink]").click();
cy.contains("Bring online");
cy.get("#NYC-switch").click({force: true});
cy.contains("Operation bring online on site NYC has started.");
cy.contains("Take offline");

//Starting state transfer
cy.get("[data-cy=NYC-startTransfer]").click();
cy.get("[data-cy=startTransferButton]").click();
cy.contains("Operation state transfer on site NYC has started.");
cy.contains("Transfer Ok");
cy.contains("Clear state"); //NYC-clearStateButton

//Verifying that as the backup site is taken offline neither of the changes is visible on the backup site.
cy.origin('http://localhost:31222/console/', () => {
cy.visit("/", {
headers: {
'Accept-Encoding': 'gzip, deflate, br'
},
auth: {
username: Cypress.env('username'),
password: Cypress.env('password')
}
});
cy.contains("Site: NYC");
cy.contains("xsiteCache").click();
cy.contains('1 - 6 of 6');
cy.contains("stringKey");
cy.contains("key5"); //The key5 should still be there as the state transfer doesn't include the entry deletions;
cy.contains("value31");
});
});

it('successfully clears state', () => {
cy.contains("xsiteCache").click();
//Going to manage Backups page and bringing the backup site online
cy.get("[data-cy=manageBackupsLink]").click();
cy.contains("Take offline");
cy.contains("Transfer Ok");
cy.get("[data-cy=NYC-clearStateButton]").click();
cy.contains("Operation clear state transfer state on site NYC has started.");
cy.contains("Transfer Ok").should("not.exist");
cy.contains("Clear state").should("not.exist");
cy.contains("Start transfer");
});
});

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
"bundle-profile:analyze": "npm run build:bundle-profile && webpack-bundle-analyzer ./stats.json",
"clean": "rimraf dist",
"deploy-console-to-server": "cp -r ./dist/* ./server/infinispan-server/static/console",
"cy:run": "cypress run --headless",
"cy:e2e": "cypress open"
"cy:run": "cypress run --headless --spec 'cypress/e2e/!(xsite.cy.js)'",
"cy:e2e": "cypress open",
"cy:run-xsite": "cypress run --headless --spec 'cypress/e2e/xsite.cy.js'"
},
"prettier": {
"parser": "typescript",
Expand Down
27 changes: 27 additions & 0 deletions run-xsite-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -e

echo "Building console."
npm run build

echo "Starting docker containers"
cd scripts/docker-compose
docker-compose up &

# 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
curl --fail --silent --show-error --retry-all-errors --retry 240 --retry-delay 1 http://localhost:31222/rest/v2/cache-managers/default/health/status > /dev/null

echo "Servers are ready."

echo "Creating data on the Server."
./create-xsite-data.sh

trap 'docker-compose down' EXIT

echo "Starting to run the tests."

npm run cy:run-xsite

echo "Test execution finished."
21 changes: 21 additions & 0 deletions scripts/docker-compose/create-xsite-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
echo "= Init create data"
echo "= Clear all data"
curl -XDELETE --BASIC -u admin:password http://localhost:11222/rest/v2/caches/xsiteCache
curl -XDELETE --BASIC -u admin:password http://localhost:31222/rest/v2/caches/xsiteCache

echo "= Create X-Site Cache"
curl -XPOST --BASIC -u admin:password -H "Content-Type: application/xml" -d "@ispn-lon.xml" http://localhost:11222/rest/v2/caches/xsiteCache
curl -XPOST --BASIC -u admin:password -H "Content-Type: application/xml" -d "@ispn-nyc.xml" http://localhost:31222/rest/v2/caches/xsiteCache

echo "= Put 5 entries in XSite cache"
for i in {1..5}
do
URL='http://localhost:11222/rest/v2/caches/xsiteCache/key'$i
DATA='{
"_type": "string",
"_value": "value'$i'"
}'
curl -XPOST --BASIC -u admin:password -d "$DATA" -H 'Content-Type: application/json' $URL
done

echo "= End"
Loading

0 comments on commit 0472967

Please sign in to comment.