Skip to content

Commit 089aae3

Browse files
authored
Merge pull request #14 from archivesspace/pilot-phase
Pilot phase
2 parents 9629051 + d5d5c73 commit 089aae3

27 files changed

+795
-65
lines changed

.github/workflows/cucumber-tests.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Cucumber
2+
on: push
3+
jobs:
4+
cucumber:
5+
name: Run Tests
6+
runs-on: ubuntu-latest
7+
concurrency:
8+
group: ci-${{ github.ref }}
9+
cancel-in-progress: true
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v2
13+
- name: Set up Docker
14+
run: |
15+
docker compose -f docker-compose.yml up --quiet-pull --detach
16+
- name: Wait until the web server is ready
17+
run: until curl -s -f -o /dev/null "http://localhost:8080"; do sleep 5; done
18+
- name: Set up Ruby
19+
uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: '3.2.0'
22+
- name: Cache gems
23+
uses: actions/cache@v2
24+
with:
25+
path: vendor/bundle
26+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-gems-
29+
- name: Install gems
30+
run: |
31+
bundle config path vendor/bundle
32+
bundle install --quiet --jobs 4 --retry 3
33+
- name: Run rubocop
34+
run: |
35+
bundle exec rubocop
36+
- name: Run tests
37+
run: |
38+
bundle exec cucumber HEADLESS=true HOST=localhost staff_features/

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
.byebug_history

.rubocop.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# .rubocop.yml
2+
3+
AllCops:
4+
NewCops: enable
5+
6+
Metrics/AbcSize:
7+
Max: 50
8+
9+
Metrics/MethodLength:
10+
Max: 50
11+
12+
Layout/ElseAlignment:
13+
Enabled: false
14+
15+
Style/ConditionalAssignment:
16+
Enabled: false

Gemfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# frozen_string_literal: true
22

3-
source "https://rubygems.org"
3+
source 'https://rubygems.org'
44

55
gem 'byebug'
66
gem 'capybara'
77
gem 'cucumber'
8+
gem 'cuke_linter'
9+
gem 'rspec-expectations'
10+
gem 'rubocop-packaging', require: false
811
gem 'selenium-webdriver'

Gemfile.lock

+36
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ GEM
33
specs:
44
addressable (2.8.7)
55
public_suffix (>= 2.0.2, < 7.0)
6+
ast (2.4.2)
67
base64 (0.2.0)
78
bigdecimal (3.1.8)
89
builder (3.3.0)
@@ -41,22 +42,53 @@ GEM
4142
cucumber-messages (> 19, < 25)
4243
cucumber-messages (22.0.0)
4344
cucumber-tag-expressions (6.1.0)
45+
cuke_linter (1.3.0)
46+
cuke_modeler (>= 1.5, < 4.0)
47+
cuke_modeler (3.21.0)
48+
cucumber-gherkin (< 29.0)
4449
diff-lcs (1.5.1)
4550
ffi (1.17.0-x86_64-linux-gnu)
51+
json (2.7.2)
52+
language_server-protocol (3.17.0.3)
4653
logger (1.6.0)
4754
matrix (0.4.2)
4855
mini_mime (1.1.5)
4956
multi_test (1.1.0)
5057
nokogiri (1.16.7-x86_64-linux)
5158
racc (~> 1.4)
59+
parallel (1.26.3)
60+
parser (3.3.4.2)
61+
ast (~> 2.4.1)
62+
racc
5263
public_suffix (6.0.1)
5364
racc (1.8.1)
5465
rack (3.1.7)
5566
rack-test (2.1.0)
5667
rack (>= 1.3)
68+
rainbow (3.1.1)
5769
regexp_parser (2.9.2)
5870
rexml (3.3.4)
5971
strscan
72+
rspec-expectations (3.13.2)
73+
diff-lcs (>= 1.2.0, < 2.0)
74+
rspec-support (~> 3.13.0)
75+
rspec-support (3.13.1)
76+
rubocop (1.65.1)
77+
json (~> 2.3)
78+
language_server-protocol (>= 3.17.0)
79+
parallel (~> 1.10)
80+
parser (>= 3.3.0.2)
81+
rainbow (>= 2.2.2, < 4.0)
82+
regexp_parser (>= 2.4, < 3.0)
83+
rexml (>= 3.2.5, < 4.0)
84+
rubocop-ast (>= 1.31.1, < 2.0)
85+
ruby-progressbar (~> 1.7)
86+
unicode-display_width (>= 2.4.0, < 3.0)
87+
rubocop-ast (1.32.1)
88+
parser (>= 3.3.1.0)
89+
rubocop-packaging (0.5.2)
90+
rubocop (>= 1.33, < 2.0)
91+
ruby-progressbar (1.13.0)
6092
rubyzip (2.3.2)
6193
selenium-webdriver (4.23.0)
6294
base64 (~> 0.2)
@@ -67,6 +99,7 @@ GEM
6799
strscan (3.1.0)
68100
sys-uname (1.3.0)
69101
ffi (~> 1.1)
102+
unicode-display_width (2.5.0)
70103
websocket (1.2.11)
71104
xpath (3.2.0)
72105
nokogiri (~> 1.8)
@@ -78,6 +111,9 @@ DEPENDENCIES
78111
byebug
79112
capybara
80113
cucumber
114+
cuke_linter
115+
rspec-expectations
116+
rubocop-packaging
81117
selenium-webdriver
82118

83119
BUNDLED WITH

README.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## Archives Space End-to-End Tests
2+
3+
### Setup
4+
5+
#### Install Ruby
6+
7+
The currently required Ruby version is in the root folder inside the [.ruby-version](https://github.com/archivesspace/e2e-tests/blob/master/.ruby-version) file.
8+
9+
It is strongly recommended to use a Ruby version manager to be able to switch to any version.
10+
The most popular version manager available for `Linux` and `macOS`, is `rbenv`.
11+
You can find the installation guide here [https://github.com/rbenv/rbenv#readme](https://github.com/rbenv/rbenv#readme).
12+
If you are on `Windows`, a separate `rbenv` installer exists here: [https://github.com/RubyMetric/rbenv-for-windows#readme](https://github.com/RubyMetric/rbenv-for-windows#readme).
13+
If you wish to use a different manager or installation method, you can choose one of the following: [https://www.ruby-lang.org/en/documentation/installation/](https://www.ruby-lang.org/en/documentation/installation/)
14+
15+
16+
#### How to install
17+
18+
Clone this repository on your machine, navigate to the root application folder, and run:
19+
20+
21+
```sh
22+
rbenv install
23+
```
24+
25+
```sh
26+
gem install bundler
27+
```
28+
29+
```sh
30+
bundle install
31+
```
32+
33+
### How to run the tests
34+
35+
#### Run on the remote host
36+
To run the tests on the `https://e2e.archivesspace.org`, run:
37+
```
38+
bundle exec cucumber
39+
```
40+
41+
#### Run on localhost
42+
To run the tests on localhost, you have to setup the application with:
43+
44+
```
45+
docker compose -f docker-compose.yml up
46+
```
47+
48+
Wait until everything is up and running.
49+
You can check if the staff interface is running on `http://localhost:8080`.
50+
51+
Then, to run the tests, open another terminal, and run:
52+
```
53+
bundle exec cucumber HOST=localhost staff_features/
54+
```
55+
56+
### Linters
57+
```
58+
bundle exec cuke_linter
59+
```
60+
61+
```
62+
bundle exec rubocop
63+
```

cucumber.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
default: |
2-
staff-features
2+
staff_features
33
--publish-quiet
44
--format pretty
55
--color
66
--require env.rb
77
--require helpers
8-
--require staff-features
8+
--require staff_features

docker-compose.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: "3"
2+
services:
3+
app:
4+
image: archivesspace/archivesspace:latest
5+
container_name: archivesspace
6+
restart: on-failure
7+
ports:
8+
- "8080:8080"
9+
- "8081:8081"
10+
- "8082:8082"
11+
- "8089:8089"
12+
- "8090:8090"
13+
depends_on:
14+
- db
15+
- solr
16+
environment:
17+
APPCONFIG_DB_URL: "jdbc:mysql://db:3306/archivesspace?useUnicode=true&characterEncoding=UTF-8&user=as&password=as123&useSSL=false&allowPublicKeyRetrieval=true"
18+
APPCONFIG_FRONTEND_PROXY_URL: "http://localhost:8080"
19+
APPCONFIG_PUBLIC_PROXY_URL: "http://localhost:8081"
20+
APPCONFIG_SOLR_URL: "http://solr:8983/solr/archivesspace"
21+
ASPACE_DB_MIGRATE: true
22+
ASPACE_JAVA_XMX: "-Xmx2048m"
23+
JAVA_OPTS: "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xss1024k -Djavax.accessibility.assistive_technologies=''"
24+
DB_ADDR: db
25+
DB_NAME: archivesspace
26+
DB_USER: as
27+
DB_PASS: as123
28+
SOLR_URL: http://solr:8983/solr/archivesspace
29+
db:
30+
image: mysql:8
31+
cap_add:
32+
- SYS_NICE
33+
container_name: mysql
34+
command: --character-set-server=utf8 --collation-server=utf8_unicode_ci --innodb_buffer_pool_size=1G --innodb_buffer_pool_instances=2 --log_bin_trust_function_creators=1
35+
ports:
36+
- "3306:3306"
37+
environment:
38+
MYSQL_ROOT_PASSWORD: "123456"
39+
MYSQL_DATABASE: archivesspace
40+
MYSQL_USER: as
41+
MYSQL_PASSWORD: as123
42+
solr:
43+
image: archivesspace/solr:latest
44+
command: solr-create -p 8983 -c archivesspace -d archivesspace
45+
environment:
46+
SOLR_JAVA_MEM: "-Xms2g -Xmx2g"
47+
ports:
48+
- "8983:8983"

env.rb

+34-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
1+
# frozen_string_literal: true
2+
3+
require 'byebug'
14
require 'capybara/cucumber'
25
require 'selenium-webdriver'
36

4-
BASE_URL = 'https://e2e.archivesspace.org'
5-
PUBLIC_URL = BASE_URL
6-
STAFF_URL = "#{BASE_URL}/staff"
7+
case ENV.fetch('HOST', nil)
8+
when 'localhost', 'http://localhost:8080'
9+
BASE_URL = 'http://localhost:8080'
10+
PUBLIC_URL = 'http://localhost:8081'
11+
STAFF_URL = BASE_URL
12+
else
13+
BASE_URL = 'https://e2e.archivesspace.org'
14+
PUBLIC_URL = BASE_URL.freeze
15+
STAFF_URL = "#{BASE_URL}/staff".freeze
16+
end
17+
18+
case ENV.fetch('HEADLESS', nil)
19+
when 'true'
20+
HEADLESS = '--headless'
21+
else
22+
HEADLESS = ''
23+
end
724

825
Capybara.register_driver :firefox do |app|
926
options = Selenium::WebDriver::Firefox::Options.new
27+
options.add_argument(HEADLESS)
1028

11-
Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
29+
Capybara::Selenium::Driver.new(app, browser: :firefox, options:)
1230
end
1331

1432
Capybara.default_driver = :firefox
1533
Capybara.default_max_wait_time = 10
34+
35+
BeforeAll do
36+
connection_error = "\nNo server found running on #{STAFF_URL}.\n\n"
37+
38+
begin
39+
response = Net::HTTP.get_response(URI(STAFF_URL))
40+
41+
raise connection_error if response.code != '200'
42+
rescue Errno::ECONNREFUSED, Errno::ECONNRESET
43+
raise connection_error
44+
end
45+
end

0 commit comments

Comments
 (0)