Skip to content

Commit d3558bc

Browse files
JaymeeHtpendragon
andauthored
Integrate TigerData into the Nomad infrastructure (#1669)
* Testing pulibrary resource class * give permission to install * add sudo * moving apt install -y command * adding circleci ruby orb installing ruby from gemfile * add node js orb and install node version from gemfile * updating gem and yarn keys * brew installing coreutiles and updating datacite version * swapping docker commands for podman * adding docker io to podman pull command * removing mac address assignment * swapping docker commands for podman in the postgres commands * adding tzdata to dependencies * add docker cleanup command * adding browser tools orbs and steps * swapping selenium headless for chrome adding capybara configurations * running mediaflux as root * re-adding mac address to mediaflux * adding sudo to other mediaflux commands * disabling cgroup * stop mediaflux as root and circleci * setting rails env variable * only publish ports * adding sudo to podman prune * adding host to mediaflux * splitting stop postgres and mediaflux commands * running postgres as root * disabling cgroup for postgres * Try this. * Try this. * removing privilege from mediaflux * adding -v command to the rootless pod * testing integration tests * revert change * Testing integration tests again * testing with princeton domain * hard coding test password * reverting password and excluding integration tests * changing mediaflux password to mediaflux ci password * revert password name change * testing integration tests in a privileged container * testing integration tests in a privileged container with hard coded password * removing privilege from mediaflux and disabling apparmor * disable seccomp * excluding integration tests and removing extra security opt tags * attempting to allow SHA1 on the Top Level Pod-container * testing integration tests AGAIN.... * delay the crypto policy update * increase delay * run crypto policy update faster * exclude integration tests * install crypto-policies and run the policy * update the crypto policy * test integration * exclude integration tests * test crypto policy update * disable sha1 after the test suite is done * disable sha1 after the test suite is done, for real this time * testing default sha1 * running the entire test suite --------- Co-authored-by: Trey Pendragon <[email protected]>
1 parent 78f796b commit d3558bc

File tree

5 files changed

+94
-40
lines changed

5 files changed

+94
-40
lines changed

.circleci/config.yml

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ parameters:
1414
default: ""
1515

1616
orbs:
17+
browser-tools: circleci/[email protected]
1718
coveralls: coveralls/[email protected]
19+
ruby: circleci/[email protected]
20+
node: circleci/[email protected]
1821
executors:
1922
basic-executor:
2023
docker:
@@ -27,11 +30,11 @@ executors:
2730
commands:
2831
install_dependencies:
2932
steps:
30-
- run: sudo apt update && sudo apt install postgresql-client libmsgpack-dev libpq-dev
33+
- run: sudo apt update && sudo apt install -y postgresql-client libmsgpack-dev libpq-dev tzdata crypto-policies
3134
- run: gem install bundler -v '2.5.6'
3235
- run: cp Gemfile.lock Gemfile.lock.bak
3336
- restore_cache:
34-
key: &gem_key tiger_data-cimg-{{ checksum "Gemfile.lock.bak" }}
37+
key: &gem_key tiger_data-cimg-{{ checksum "Gemfile.lock.bak" }}-2
3538
- run: bundle config set path './vendor/bundle'
3639
- run: bundle config set --local without production
3740
- run: bundle install --jobs=4 --retry=3
@@ -41,7 +44,7 @@ commands:
4144
- ./vendor/bundle
4245
- restore_cache:
4346
name: Restore Yarn Package Cache
44-
key: &yarn_key tiger_data-yarn-cimg-{{ checksum "yarn.lock" }}
47+
key: &yarn_key tiger_data-yarn-cimg-{{ checksum "yarn.lock" }}-2
4548
- run:
4649
name: Install NPM Dependencies via Yarn
4750
command: yarn install --frozen-lockfile
@@ -53,29 +56,64 @@ commands:
5356

5457
run_mediaflux:
5558
steps:
56-
- run: echo "$DOCKERHUB_PASSWORD" | docker login --username $DOCKERHUB_USERNAME --password-stdin
57-
- run: docker pull pulibraryrdss/mediaflux_dev:v0.8.0
58-
- run: docker run -d --privileged --name mediaflux --publish 0.0.0.0:8888:80 --mac-address 02:42:ac:11:00:02 pulibraryrdss/mediaflux_dev:v0.8.0
59+
- run:
60+
name: Run Mediaflux in podman
61+
command: podman run -t --name mediaflux --rm --security-opt label=disable --security-opt unmask=ALL -p 8888:8888 --user podman --device /dev/net/tun --device /dev/fuse quay.io/podman/stable:latest bin/bash -c "echo $DOCKERHUB_PASSWORD | podman login --username $DOCKERHUB_USERNAME --password-stdin docker.io && podman run -t --rm -v /sys:/sys -p 8888:80 --device /dev/fuse --network bridge --mac-address=02:42:ac:11:00:02 docker.io/pulibraryrdss/mediaflux_dev:v0.8.0"
62+
background: true
63+
64+
# Enable SHA1 for Mediaflux. Neccessary to run integration tests
65+
enable_sha1_for_mediaflux:
66+
steps:
67+
- run:
68+
name: Update the Crypto Policies of the Top Level Pod-Container
69+
command: sudo update-crypto-policies --set LEGACY
70+
background: true
71+
72+
# Disable SHA1 for security purposes
73+
disable_sha1:
74+
steps:
75+
- run:
76+
name: Update the Crypto Policies of the Top Level Pod-Container
77+
command: sudo update-crypto-policies --set DEFAULT
78+
background: true
5979

6080
run_postgres:
6181
steps:
62-
- run: docker create --name postgres --publish 0.0.0.0:5432:5432 --env POSTGRES_HOST_AUTH_METHOD=trust --env POSTGRES_DB=test_db --env POSTGRES_USER=tiger_data_user postgres:15.2-alpine
63-
- run: docker start postgres
82+
- run:
83+
name: Run Postgres in podman
84+
command: podman run -t --name postgres --rm --publish 0.0.0.0:5432:5432 --env POSTGRES_HOST_AUTH_METHOD=trust --env POSTGRES_DB=test_db --env POSTGRES_USER=tiger_data_user docker.io/postgres:15.2-alpine
85+
background: true
86+
87+
cleanup_docker:
88+
steps:
89+
- run: podman stop postgres || true
90+
- run: podman stop mediaflux || true
91+
- run: podman system prune -a --volumes -f || true
6492

6593
jobs:
6694
test:
6795
working_directory: ~/tiger_data
68-
machine:
69-
image: ubuntu-2404:2024.05.1
70-
docker_layer_caching: true
96+
machine: true
97+
resource_class: pulibrary/ruby-deploy
7198
environment:
7299
POSTGRES_USER: tiger_data_user
73100
POSTGRES_DB: test_db
74101
POSTGRES_HOST_AUTH_METHOD: trust
75102
ARCH: linux
103+
RAILS_ENV: test
76104
steps:
77105
- checkout
106+
- cleanup_docker
107+
- run_mediaflux
108+
- ruby/install:
109+
version: "3.3.0"
110+
- node/install:
111+
install-yarn: true
112+
node-version: "22.9"
113+
- browser-tools/install-chrome
114+
- browser-tools/install-chromedriver
78115
- install_dependencies
116+
- run_postgres
79117
- run:
80118
name: Run rubocop
81119
command: bundle exec rubocop
@@ -86,17 +124,17 @@ jobs:
86124
- run:
87125
name: Run eslint
88126
command: yarn run eslint 'app/javascript/**'
127+
# wait for postgres and mediaflux
128+
- run: sleep 10
129+
- enable_sha1_for_mediaflux
89130
- persist_to_workspace:
90131
root: &root "~/tiger_data"
91132
paths: "*"
92-
- run_mediaflux
93-
- run_postgres
94-
# wait for postgres and mediaflux
95-
- run: sleep 10
96133
- run: bundle exec rake db:migrate RAILS_ENV=test
97134
- run:
98135
name: Run Rspec
99-
command: bundle exec rspec --tag \~integration --format progress --format RspecJunitFormatter -o /tmp/rspec/rspec.xml
136+
command: bundle exec rspec --format progress --format RspecJunitFormatter -o /tmp/rspec/rspec.xml
137+
- disable_sha1
100138
- store_test_results:
101139
path: /tmp/rspec
102140
- store_artifacts:

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ gem "devise"
5757
gem "omniauth-cas", "~> 3.0"
5858

5959
gem "csv"
60-
gem "datacite", github: "sul-dlss/datacite-ruby", branch: "main"
60+
gem "datacite", "~> 0.4.0"
6161
gem "dogstatsd-ruby"
6262
gem "dry-operation"
6363
gem "flipflop"

Gemfile.lock

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
GIT
2-
remote: https://github.com/sul-dlss/datacite-ruby.git
3-
revision: 9da880e450881f33700071b26ff28170b6b4f5bc
4-
branch: main
5-
specs:
6-
datacite (0.3.0)
7-
dry-monads (~> 1.3)
8-
faraday (~> 2.0)
9-
json_schema (~> 0.21.0)
10-
zeitwerk (~> 2.4)
11-
121
GEM
132
remote: https://rubygems.org/
143
specs:
@@ -156,6 +145,11 @@ GEM
156145
crass (1.0.6)
157146
csv (3.3.0)
158147
daemons (1.4.1)
148+
datacite (0.4.0)
149+
dry-monads (~> 1.3)
150+
faraday (~> 2.0)
151+
json_schema (~> 0.21.0)
152+
zeitwerk (~> 2.4)
159153
date (3.4.1)
160154
descendants_tracker (0.0.4)
161155
thread_safe (~> 0.3, >= 0.3.1)
@@ -169,12 +163,13 @@ GEM
169163
docile (1.4.0)
170164
dogstatsd-ruby (5.6.1)
171165
dry-cli (1.0.0)
172-
dry-core (1.0.1)
166+
dry-core (1.1.0)
173167
concurrent-ruby (~> 1.0)
168+
logger
174169
zeitwerk (~> 2.6)
175-
dry-monads (1.6.0)
170+
dry-monads (1.9.0)
176171
concurrent-ruby (~> 1.0)
177-
dry-core (~> 1.0, < 2)
172+
dry-core (~> 1.1)
178173
zeitwerk (~> 2.6)
179174
dry-operation (1.0.0)
180175
dry-monads (~> 1.6)
@@ -189,10 +184,12 @@ GEM
189184
factory_bot_rails (6.4.3)
190185
factory_bot (~> 6.4)
191186
railties (>= 5.0.0)
192-
faraday (2.9.0)
193-
faraday-net_http (>= 2.0, < 3.2)
194-
faraday-net_http (3.1.0)
195-
net-http
187+
faraday (2.13.4)
188+
faraday-net_http (>= 2.0, < 3.5)
189+
json
190+
logger
191+
faraday-net_http (3.4.1)
192+
net-http (>= 0.5.0)
196193
faye-websocket (0.11.3)
197194
eventmachine (>= 0.12.0)
198195
websocket-driver (>= 0.5.1)
@@ -224,6 +221,7 @@ GEM
224221
jbuilder (2.12.0)
225222
actionview (>= 5.0.0)
226223
activesupport (>= 5.0.0)
224+
json (2.13.2)
227225
json_schema (0.21.0)
228226
kaminari (1.2.2)
229227
activesupport (>= 4.1.0)
@@ -265,7 +263,7 @@ GEM
265263
mustermann (3.0.0)
266264
ruby2_keywords (~> 0.0.1)
267265
mutex_m (0.2.0)
268-
net-http (0.4.1)
266+
net-http (0.6.0)
269267
uri
270268
net-http-persistent (4.0.2)
271269
connection_pool (~> 2.2)
@@ -495,7 +493,7 @@ GEM
495493
tzinfo (2.0.6)
496494
concurrent-ruby (~> 1.0)
497495
unicode-display_width (2.5.0)
498-
uri (0.13.2)
496+
uri (1.0.3)
499497
virtus (2.0.0)
500498
axiom-types (~> 0.1)
501499
coercible (~> 1.0)
@@ -551,7 +549,7 @@ DEPENDENCIES
551549
capybara
552550
coveralls_reborn
553551
csv
554-
datacite!
552+
datacite (~> 0.4.0)
555553
devise
556554
dogstatsd-ruby
557555
dry-operation

spec/rails_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
if ENV["RUN_IN_BROWSER"]
8585
driven_by(:selenium)
8686
else
87-
driven_by(:selenium_headless)
87+
driven_by(:chrome_headless)
8888
end
8989
end
9090
end

spec/support/system_specs.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
# frozen_string_literal: true
2+
Capybara.configure do |config|
3+
config.default_driver = :chrome_headless
4+
end
5+
6+
Capybara.register_driver :chrome_headless do |app|
7+
client = Selenium::WebDriver::Remote::Http::Default.new
8+
client.read_timeout = 120
9+
options = Selenium::WebDriver::Chrome::Options.new(args: %w[disable-gpu no-sandbox headless whitelisted-ips window-size=1400,1400])
10+
options.add_argument(
11+
"--enable-features=NetworkService,NetworkServiceInProcess"
12+
)
13+
options.add_argument("--profile-directory=Default")
14+
options.add_argument("--disable-dev-shm-usage")
15+
16+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, http_client: client)
17+
end
18+
19+
Capybara.javascript_driver = :chrome_headless
220

321
RSpec.configure do |config|
422
config.before(:each, type: :system) do
@@ -9,7 +27,7 @@
927
if ENV["RUN_IN_BROWSER"]
1028
driven_by(:selenium)
1129
else
12-
driven_by(:selenium_headless)
30+
driven_by(:chrome_headless)
1331
end
1432
end
1533
config.before(:each, type: :system, js: true, in_browser: true) do

0 commit comments

Comments
 (0)