Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Added acceptance tests container #6

Merged
merged 1 commit into from
Nov 27, 2017
Merged

Added acceptance tests container #6

merged 1 commit into from
Nov 27, 2017

Conversation

mamedin
Copy link
Contributor

@mamedin mamedin commented Sep 22, 2017

This pull request tries to fix #2. It was originally submitted by @mamedin but it has received contributions from other developers.

The goal is to make possible to run the acceptance tests in our Docker Compose environment. We've added a new docker-compose.acceptance-tests.yml configuration file that adds four new services:

  • selenium-hub (Java daemon)
  • selenium-firefox (Firefox node)
  • selenium-chrome (Chrome node)
  • archivematica-acceptance-tests (behave + tests)

behave uses its webdriver to communicate with selenium-hub. The hub receives the tests to be executed along with information on which browser and platform where the test should be run. The hub will use this information and delegate to a node that can service those needs.

It's easier to understand it just by looking at this simple behave test that we've added to verify that the selenium infra is working: https://github.com/artefactual-labs/archivematica-acceptance-tests/blob/acceptance-tests-docker/simplehubtest.py. This test can be executed with make test-at-check.

Other test-at-* targets have been added to our Makefile. Run make help to obtain the full list.

@mamedin mamedin requested a review from sevein September 22, 2017 19:26
@sevein
Copy link
Member

sevein commented Sep 23, 2017

The pipeline hostname has to be changed to archivematica-dashboard:8000 on the Storage Service after running make bootstrap.

Related: artefactual/archivematica-storage-service#236

@scollazo scollazo self-requested a review October 23, 2017 20:25
Copy link

@scollazo scollazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using xvnc instead of xvfb allows for easy troubleshooting, as the X session is exposed using vnc

@sevein
Copy link
Member

sevein commented Oct 23, 2017

@scollazo this is being designed with CI in mind where human interaction isn't a priority. To my knowledge Xvfb seemed simpler and still had the ability to take screenshots. Wouldn't that be enough?

@scollazo
Copy link

vnc allows for things like recording videos from the session in an easyer way, and also it would be useful when using this in a standalone way, not hooked to ci/cd

@jhsimpson
Copy link
Member

jhsimpson commented Oct 23, 2017 via email

@sevein
Copy link
Member

sevein commented Oct 23, 2017

These are really nice ideas, having more than one option would be great. I wonder though if we should focus first on getting the simplest way possible working (afaik that's Xvfb), have CI running it automatically for us and then look into your ideas as separate issues? e.g. Problem: UAT can't record videos or Problem: user can't interact with UI in UAT?

At this point I think that the biggest change that @mamedin's work needs is to make some tweaks in the entry point of the container so we can run the tests exactly when we want to without having to edit the script and rebuild the image. E.g. I suggest to replace make restart-tests with make run-acceptance-tests, this is how it'd be used:

$ ansible-playbook ../playbooks/download-sources.yml
$ make create-volumes
$ docker-compose up -d --build
$ make bootstrap
$ make run-acceptance-tests

The problem with the existing entry point is that it doesn't take inputs:

#!/bin/sh
rm -rf /tmp/.X99-lock /tmp/.X11-unix/X99 &
Xvfb -ac :99 -screen 0 1920x1080x8 -nolisten tcp & 
cd /home/archivematica/test/ 
./no_test.sh
#./firefox_am17_tests.sh
#./chrome_am17_tests.sh

We could replace it with something like the following:

#!/usr/bin/env bash

set -ex

if [ $# -eq 0 ]; then
    echo "No arguments supplied."
    exit 0
fi

firefox=false
chrome=false

for arg in "$@"
do
    case $arg in
        "firefox" )
           firefox=true;;
        "chrome" )
           chrome=true;;
        "all" )
           firefox=true; chrome=true;;
   esac
done

if [ "$firefox" = true ]; do
    ./firefox_am17_tests.sh
done

if [ "$chrome" = true ]; do
    ./chrome_am17_tests.sh
done

The implementation of make run-acceptance-tests would be as simple as:

$ docker-compose run --rm archivematica-acceptance-tests all

That all argument will be passed to the previous script because it's defined as the entrypoint. If we wanted to collect some screenshots we could set up a bind mount in the Compose file.

@sevein
Copy link
Member

sevein commented Oct 25, 2017

I've rebased this, now it's using git submodules. I've also made some changes on top of @mamedin's work. Instead of building our own images which proved to be really hard, I've added a new docker-compose.acceptance-tests.yml that extends docker-compose.yml with new services based on the public Docker images built by SeleniumHQ. We provision a Selenium Standalone Server and Firefox/Chrome services plus an extra service that we use to launch the actual tests.

These containers seem to be pretty flexible and they can be complemented with other alternatives that they provide with VNC and virtual desktop environments. Also they use recent versions of the browsers and web drivers (geckodriver and chromedriver). More details here: https://github.com/SeleniumHQ/docker-selenium.

Please revisit the diff for more details. I've added some docs. They don't explain how to use VNC


There is an extra Compose file called `docker-compose.acceptance-tests.yml` that defines some extra services to run our acceptance tests, e.g. Selenium Standalone Server, Selenium Chrome Node or Selenium Firefox Node. In order to run the tests use the following command:

$ make at-run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to support passing arguments to behave, e.g.:

$ make ARGS="--tags=@wip" at-run

CHROME_VERSION: "google-chrome-stable"
CHROME_DRIVER_VERSION: "latest"
HUB_PORT_4444_TCP_ADDR: "selenium-hub"
HUB_PORT_4444_TCP_PORT: "4444"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it defaults to hub (instead of selenium-hub), but I can rename the link below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I do in the archivematica-acceptance-tests service.

@sevein
Copy link
Member

sevein commented Nov 17, 2017

Rebased.

@sevein sevein force-pushed the dev/acceptance-tests branch 3 times, most recently from ac2a428 to aa435d7 Compare November 17, 2017 17:37
@sevein
Copy link
Member

sevein commented Nov 17, 2017

Rebased and squashed.

@jrwdunham
Copy link
Contributor

jrwdunham commented Nov 20, 2017

At 70b45f3 I was able to run make test-at-run-firefox and successfully get one test to pass:

@am16
Feature: Metadata-only AIP re-ingest # features/core/metadata-only-aip-reingest.feature:2
  Users want to be able to take an existing AIP and perform a metadata-only
  re-ingest on it so that they can add metadata to it and confirm that those
  metadata are in the re-ingested AIP's METS file.
  @mo-aip-reingest
  Scenario: Isla creates an AIP, and then performs a metadata-only re-ingest on it, adds metadata to it, and confirms that her newly added metadata are in the modified METS file.   # features/core/metadata-only-aip-reingest.feature:8
    Given that the user has ensured that the default processing config is in its default state                                                                                       # features/steps/steps.py:698
    And the reminder to add metadata is enabled                                                                                                                                      # features/steps/steps.py:704
    When a transfer is initiated on directory ~/archivematica-sampledata/SampleTransfers/BagTransfer                                                                                 # features/steps/steps.py:951
    And the user waits for the "Assign UUIDs to directories?" decision point to appear and chooses "No" during transfer                                                              # features/steps/steps.py:76
    And the user waits for the "Select file format identification command" decision point to appear and chooses "Identify using Fido" during transfer                                # features/steps/steps.py:76
    And the user waits for the "Perform policy checks on originals?" decision point to appear and chooses "No" during transfer                                                       # features/steps/steps.py:76
    And the user waits for the "Create SIP(s)" decision point to appear and chooses "Create single SIP and continue processing" during transfer                                      # features/steps/steps.py:76
    And the user waits for the "Normalize" decision point to appear and chooses "Normalize for preservation" during ingest                                                           # features/steps/steps.py:76
    And the user waits for the "Approve normalization (review)" decision point to appear and chooses "Approve" during ingest                                                         # features/steps/steps.py:76
    And the user waits for the "Perform policy checks on preservation derivatives?" decision point to appear and chooses "No" during ingest                                          # features/steps/steps.py:76
    And the user waits for the "Perform policy checks on access derivatives?" decision point to appear and chooses "No" during ingest                                                # features/steps/steps.py:76
    And the user waits for the "Reminder: add metadata if desired" decision point to appear and chooses "Continue" during ingest                                                     # features/steps/steps.py:76
    And the user waits for the "Select file format identification command|Process submission documentation" decision point to appear and chooses "Identify using Fido" during ingest # features/steps/steps.py:76
    And the user waits for the "Bind PIDs?" decision point to appear and chooses "No" during ingest                                                                                  # features/steps/steps.py:76
    And the user waits for the "Store AIP (review)" decision point to appear during ingest                                                                                           # features/steps/steps.py:58
    Then in the METS file the metsHdr element has a CREATEDATE attribute but no LASTMODDATE attribute                                                                                # features/steps/steps.py:799
    And in the METS file the metsHdr element has two dmdSec next sibling element(s)                                                                                                  # features/steps/steps.py:822
    When the user chooses "Store AIP" at decision point "Store AIP (review)" during ingest                                                                                           # features/steps/steps.py:88
    And the user waits for the "Store AIP location" decision point to appear and chooses "Store AIP in standard Archivematica Directory" during ingest                               # features/steps/steps.py:76
    And the user waits for the AIP to appear in archival storage                                                                                                                     # features/steps/steps.py:108
    And the user initiates a metadata-only re-ingest on the AIP                                                                                                                      # features/steps/steps.py:643
    And the user waits for the "Approve AIP reingest" decision point to appear and chooses "Approve AIP reingest" during ingest                                                      # features/steps/steps.py:76
    And the user waits for the "Normalize" decision point to appear and chooses "Do not normalize" during ingest                                                                     # features/steps/steps.py:76
    And the user waits for the "Perform policy checks on preservation derivatives?" decision point to appear and chooses "No" during ingest                                          # features/steps/steps.py:76
    And the user waits for the "Perform policy checks on access derivatives?" decision point to appear and chooses "No" during ingest                                                # features/steps/steps.py:76
    And the user waits for the "Reminder: add metadata if desired" decision point to appear during ingest                                                                            # features/steps/steps.py:58
    And the user adds metadata                                                                                                                                                       # features/steps/steps.py:638
    And the user chooses "Continue" at decision point "Reminder: add metadata if desired" during ingest                                                                              # features/steps/steps.py:88
    And the user waits for the "Select file format identification command|Process submission documentation" decision point to appear and chooses "Identify using Fido" during ingest # features/steps/steps.py:76
    And the user waits for the "Bind PIDs?" decision point to appear and chooses "No" during ingest                                                                                  # features/steps/steps.py:76
    And the user waits for the "Store AIP (review)" decision point to appear during ingest                                                                                           # features/steps/steps.py:58
    Then in the METS file the metsHdr element has a CREATEDATE attribute and a LASTMODDATE attribute                                                                                 # features/steps/steps.py:799
    And in the METS file the metsHdr element has three dmdSec next sibling element(s)                                                                                                # features/steps/steps.py:822
    And in the METS file the dmdSec element contains the metadata added                                                                                                              # features/steps/steps.py:849

1 feature passed, 0 failed, 11 skipped
1 scenario passed, 0 failed, 35 skipped
34 steps passed, 0 failed, 360 skipped, 0 undefined

environment:
FIREFOX_VERSION: "47.0.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this here for a reason? I noticed that https://hub.docker.com/r/selenium/node-firefox/~/dockerfile/ takes a FIREFOX_VERSION but it's a build argument not an environment variable. Is this being used somewhere else?

- "nginx"
shm_size: 2g # See https://goo.gl/dkZzHh
ports:
- "62102:5900"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the new ports to the README?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, will do.

ports:
- "62102:5900"
environment:
FIREFOX_VERSION: "47.0.1"
Copy link
Member

@sevein sevein Nov 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this here for a reason? I noticed that https://hub.docker.com/r/selenium/node-firefox/~/dockerfile/ takes a FIREFOX_VERSION but it's a build argument not an environment variable. Is this being used somewhere else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha. I don't even know if this does anything. All I know is that I got the test to pass when this was set. I'll rerun them without this and see if they pass.

@jrwdunham
Copy link
Contributor

jrwdunham commented Nov 20, 2017

TODOs:

  • Determine if FIREFOX_VERSION: "47.0.1" flag is necessary and remove if not.
  • Add new browser container ports to README
  • Improve README explaining how to run tests and debug them (use VNC viewer, etc.)
  • Modify entrypoint.sh (in AT PR) to use env vars for secrets
  • Add issue to AT asserting that we need a single sanity feature that confirms basic AM functionality and can be run in a CI system and which takes no more than 10 minutes to run. (See Problem: need a basic feature for AM sanity checking archivematica-acceptance-tests#49)

@mamedin
Copy link
Contributor Author

mamedin commented Nov 27, 2017

About the TODO checklist, I think that we are done. Please, review the latest 4 commits.

The entrypoint commit is related to artefactual-labs/archivematica-acceptance-tests#27

@sevein sevein merged commit 9949aaa into master Nov 27, 2017
@sevein sevein deleted the dev/acceptance-tests branch December 9, 2017 16:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem: can't run acceptance tests
5 participants