forked from Islandora-Devops/isle-dc
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migration derivative generation test.
- Loading branch information
Showing
6 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
BASE_TEST_FOLDER=12-migration-derivative-tests | ||
DRUPAL_CONTAINER_NAME=$(docker ps | awk '{print $NF}'|grep drupal) | ||
CURRENT_DIR=$(pwd) | ||
|
||
# The Docker registry used to obtain the migration assets image | ||
assets_repo=${MIGRATION_ASSETS_REPO:-ghcr.io/jhu-sheridan-libraries/idc-isle-dc} | ||
# The name of the Docker image for migration assets | ||
assets_image=${MIGRATION_ASSETS_IMAGE:-migration-assets} | ||
# The migration assets image tag | ||
assets_image_tag=${MIGRATION_ASSETS_IMAGE_TAG:-088c482.1617637226} | ||
# The *external* port the migration assets HTTP server listens on | ||
ext_assets_port=${MIGRATION_ASSETS_PORT:-8081} | ||
# The name used by the migration assets container | ||
assets_container=${MIGRATION_ASSETS_CONTAINER:-migration-assets} | ||
|
||
# Locate test directory | ||
if [ ! -d ${BASE_TEST_FOLDER} ] ; | ||
then | ||
BASE_TEST_FOLDER=tests/${BASE_TEST_FOLDER} | ||
if [ ! -d ${BASE_TEST_FOLDER} ] ; | ||
then | ||
echo "Missing expected test directory ${BASE_TEST_FOLDER}" | ||
exit 1 | ||
else | ||
cd ${BASE_TEST_FOLDER} | ||
fi | ||
else | ||
cd ${BASE_TEST_FOLDER} | ||
fi | ||
|
||
TESTCAFE_TESTS_FOLDER=$(pwd)/testcafe | ||
|
||
# Start the backend that serves the media files to be migrated | ||
# Listens internally on port 80 (addressed as http://<assets_container>/assets/) | ||
docker run --name ${assets_container} --network gateway --rm -d ${assets_repo}/${assets_image}:${assets_image_tag} | ||
trap "docker stop ${assets_container}" EXIT | ||
|
||
# Execute migrations using testcafe | ||
docker run --network gateway -v "${TESTCAFE_TESTS_FOLDER}":/tests testcafe/testcafe --screenshots path=/tests/screenshots,takeOnFails=true chromium /tests/**/*.js | ||
|
||
# Back to parent directory | ||
cd ${CURRENT_DIR} |
96 changes: 96 additions & 0 deletions
96
tests/12-migration-derivative-tests/testcafe/migrate_derivative.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import {Selector} from 'testcafe'; | ||
import {adminUser} from './roles.js'; | ||
|
||
|
||
fixture`Migration Derivative Tests` | ||
.page`https://islandora-idc.traefik.me/migrate_source_ui` | ||
.beforeEach(async t => { | ||
await t | ||
.useRole(adminUser); | ||
}); | ||
|
||
const migrate_new_items = 'idc_ingest_new_items'; | ||
const migrate_new_collection = 'idc_ingest_new_collection'; | ||
const migrate_media_file = 'idc_ingest_media_file'; | ||
|
||
const selectMigration = Selector('#edit-migrations'); | ||
const migrationOptions = selectMigration.find('option'); | ||
|
||
const contentList = "https://islandora-idc.traefik.me/admin/content"; | ||
|
||
test('Migrate Images for Derivative Generation', async t => { | ||
|
||
// migrate the test objects into Drupal | ||
await t | ||
.click(selectMigration) | ||
.click(migrationOptions.withAttribute('value', migrate_new_collection)); | ||
|
||
await t | ||
.setFilesToUpload('#edit-source-file', [ | ||
'./migrations/derivative-collection.csv' | ||
]) | ||
.click('#edit-import'); | ||
|
||
await t | ||
.click(selectMigration) | ||
.click(migrationOptions.withAttribute('value', migrate_new_items)) | ||
|
||
await t | ||
.setFilesToUpload('#edit-source-file', [ | ||
'./migrations/derivative-islandora_object.csv' | ||
]) | ||
.click('#edit-import'); | ||
|
||
await t | ||
.click(selectMigration) | ||
.click(migrationOptions.withAttribute('value', migrate_media_file)) | ||
|
||
await t | ||
.setFilesToUpload('#edit-source-file', [ | ||
'./migrations/derivative-file.csv' | ||
]) | ||
.click('#edit-import'); | ||
|
||
// verify the presence of the islandora object | ||
const io_name = "Derivative Repository Item One" | ||
await t.navigateTo(contentList) | ||
const io = Selector('div.view-content').find('a').withText(io_name) | ||
await t.expect(io.count).eql(1); | ||
|
||
// list its media | ||
|
||
await t.click(io) | ||
await t.click(Selector('#rid-content').find('a').withText('Media')) | ||
|
||
// assert the presence of the original media | ||
const media_name = "Map Image"; | ||
const media = Selector('div.view-content').find('a').withText(media_name); | ||
await t.expect(media.count).eql(1); | ||
|
||
// assert expected attributes of the original media | ||
await t.expect(media.parent('tr').child('td').nth(2).innerText).eql('File') | ||
await t.expect(media.parent('tr').child('td').nth(3).innerText).eql('image/tiff') | ||
await t.expect(media.parent('tr').child('td').nth(4).innerText).contains('Preservation Master File') | ||
await t.expect(media.parent('tr').child('td').nth(4).innerText).contains('Original File') | ||
|
||
// assert the presence of a derivative thumbnail and service image | ||
// (increase timeout in case derivatives haven't been created yet?) | ||
const service_derivative = Selector('div.view-content').find('a').withText('Service File.jpg'); | ||
const thumb_derivative = Selector('div.view-content').find('a').withText('Thumbnail Image.jpg'); | ||
|
||
console.log("Checking for derivatives ...") | ||
const service_count = await service_derivative.count | ||
const thumb_count = await thumb_derivative.count | ||
|
||
// if a derivative isn't present yet, it may be because it hasn't been generated yet. | ||
// in that case, wait 10 seconds and refresh the page, and see if it appears. | ||
if (service_count < 1 || thumb_count < 1) { | ||
console.log("Derivatives haven't appeared. Sleeping for 10 seconds, then trying again ...") | ||
// sleep 10 seconds, refresh the page | ||
await t.wait(10000); | ||
await t.eval(() => location.reload(true)); | ||
} | ||
|
||
await t.expect(service_derivative.count).eql(1); | ||
await t.expect(thumb_derivative.count).eql(1); | ||
}); |
2 changes: 2 additions & 0 deletions
2
tests/12-migration-derivative-tests/testcafe/migrations/derivative-collection.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
local_id,title,title_language,alternative_title,member_of,contact_email,contact_name,collection_number,description,finding_aid | ||
derivative-collection-01,Derivative Collection,eng,,,,,,Collection for Derivative tests;eng, |
2 changes: 2 additions & 0 deletions
2
tests/12-migration-derivative-tests/testcafe/migrations/derivative-file.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
local_id,name,original_name,mime_type,media_of,media_use,url | ||
derivative_media_file_00001,Map Image,map-image.tif,image/tiff,derivative_io_01,Original File|Preservation Master File,http://migration-assets/assets/image/map-image.tif |
2 changes: 2 additions & 0 deletions
2
tests/12-migration-derivative-tests/testcafe/migrations/derivative-islandora_object.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
local_id,title,abstract,access_rights,access_terms,alt_title,collection_number,contributor,copyright,copyright_holder,creator,date_available,date_copyrighted,date_created,date_published,description,digital_identifier,digital_publisher,display_hints,dspace_identifier,dspace_itemid,extent,finding_aid,genre,geoportal_link,issn,is_part_of,item_barcode,jhir_uri,language,library_catalog_link,member_of,model,oclc_number,publisher,publisher_country,resource_type,spatial_coverage,subject,table_of_contents,title_language,years | ||
derivative_io_01,Derivative Repository Item One,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,derivative-collection-01,Image,,,,,,,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Role } from 'testcafe'; | ||
|
||
/** | ||
* Drupal administrator via local login | ||
*/ | ||
export const adminUser = Role('https://islandora-idc.traefik.me/user/login', async t => { | ||
await t | ||
.typeText('#edit-name', 'admin') | ||
.typeText('#edit-pass', 'password') | ||
.click('#edit-submit'); | ||
}); |