Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bbommarito/appeals 57533 appeals 55606 #23070

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
50bf288
add metabase to m1 docker compose
craigrva Aug 26, 2024
eb9c353
rename metabase container and specify a version
craigrva Aug 26, 2024
06cc15a
add script for initial metabase setup
craigrva Aug 28, 2024
765c61b
script output formatting
craigrva Aug 28, 2024
f7cdc93
add metabase directory
craigrva Aug 28, 2024
0be4bc6
move to a dockerfile, implement VACOLS to setup script
craigrva Aug 28, 2024
d874156
add metabase to original docker-compose
craigrva Aug 28, 2024
052a707
add step to initialize metabase in demo startup
craigrva Sep 9, 2024
010beca
update demo startup.sh to initialize metabase with absolute path
craigrva Sep 9, 2024
3456dd2
add make command for local metabase setup
craigrva Sep 9, 2024
692be83
fix makefile syntax error
craigrva Sep 9, 2024
6727416
Merge branch 'master' of https://github.com/department-of-veterans-af…
craigrva Sep 17, 2024
f19bab4
Merge branch 'master' of https://github.com/department-of-veterans-af…
craigrva Sep 20, 2024
2160f10
update scripts to work in AWS
craigrva Sep 20, 2024
1683aad
update demo script to use apt-get instead of yum
craigrva Sep 20, 2024
666fcab
update demo script to use dns for vacols-db
craigrva Sep 23, 2024
8b85ec0
fix vacols DB docker DNS name
craigrva Sep 23, 2024
07e2c50
Merge pull request #22903 from department-of-veterans-affairs/dev-sup…
craigrva Sep 24, 2024
25ed7f1
hotfix/APPEALS-23420: search defect
ryanpmessner Sep 27, 2024
c231266
Revert "hotfix/APPEALS-23420: search defect" (#23011)
ronwabVa Sep 27, 2024
8faba2e
Merge branch 'main' into danielm/APPEALS-55606
bbommarito Oct 3, 2024
1f4f369
Adding tests for both complete and incomplete document loads.
bbommarito Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile.example
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ seed-dbs: ## Seed all databases
bundle exec rake spec:setup_vacols
bundle exec rake db:seed

setup-metabase:
./metabase/metabase_api_script.sh

enable-feature-flags: ## enable all feature flags
bundle exec rails runner scripts/enable_features_dev.rb

Expand Down
44 changes: 44 additions & 0 deletions client/test/app/readerprototype/components/PdfDocument.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import PdfDocument from 'app/readerprototype/components/PdfDocument';
import React from 'react';
import { act, render, waitFor } from '@testing-library/react';
import ApiUtil from 'app/util/ApiUtil';

const doc = {
content_url: '/some/file/here'
};

describe('Handling metrics for a pdf document', () => {
it('sends data when a document is fully loaded', async () => {
jest.mock('app/util/ApiUtil', () => ({
post: jest.fn(),
}));

const spy = jest.spyOn(ApiUtil, 'post');

act(async () => {
const { container } = render(<PdfDocument doc={doc} />);

container.setAllPagesRendered = true;

await waitFor(() => expect(spy).toHaveBeenCalledWith({}));
});

});

it('sends data when a document is not fully loaded', async () => {
jest.mock('app/util/ApiUtil', () => ({
post: jest.fn(),
}));

const spy = jest.spyOn(ApiUtil, 'post');

act(async () => {
const { container } = render(<PdfDocument doc={doc} />);

container.setAllPagesRendered = false;

await waitFor(() => expect(spy).toHaveBeenCalledWith({}));
});

});
});
3 changes: 3 additions & 0 deletions docker-bin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ bundle exec rails runner scripts/enable_features_dev.rb
echo "Enabling caching"
touch tmp/caching-dev.txt

echo "Initializing metabase"
/caseflow/metabase/metabase_api_script_demo.sh

echo "Starting Caseflow App RoR"
rails server --binding 0.0.0.0 -p 3000
8 changes: 8 additions & 0 deletions docker-compose-m1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,13 @@ services:
volumes:
- ./local/sqs/conf:/conf

appeals-metabase:
platform: linux/amd64
container_name: metabase
build:
context: metabase
ports:
- "3002:3000"

volumes:
postgresdata:
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,12 @@ services:
volumes:
- ./local/sqs/conf:/conf

appeals-metabase:
container_name: metabase
build:
context: metabase
ports:
- "3002:3000"

volumes:
postgresdata:
14 changes: 14 additions & 0 deletions metabase/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM metabase/metabase:v0.50.21
MAINTAINER BID Appeals

ENV MB_PLUGINS_DIR /app/plugins

WORKDIR /app
RUN addgroup --gid 2000 --system metabase
RUN adduser --disabled-password -u 2000 --ingroup metabase metabase
RUN mkdir plugins && chmod g-w plugins
RUN cd plugins && curl -sLO https://download.oracle.com/otn-pub/otn_software/jdbc/235/ojdbc8.jar

RUN chown -R metabase:metabase /app/plugins

ENTRYPOINT ["/app/run_metabase.sh"]
82 changes: 82 additions & 0 deletions metabase/metabase_api_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/sh

[email protected]
ADMIN_PASSWORD=caseflow1
[email protected]
USER_PASSWORD=caseflow1

CASEFLOW_HOST=appeals-db
VACOLS_HOST=host.docker.internal

echo "⌚︎ Waiting for Metabase to start"
while (! curl -s -m 5 http://localhost:3002/api/session/properties -o /dev/null); do sleep 5; done

echo "😎 Creating admin user"

SETUP_TOKEN=$(curl -s -m 5 -X GET \
-H "Content-Type: application/json" \
http://localhost:3002/api/session/properties \
| jq -r '.["setup-token"]'
)

MB_TOKEN=$(curl -s -X POST \
-H "Content-type: application/json" \
http://localhost:3002/api/setup \
-d '{
"token": "'${SETUP_TOKEN}'",
"user": {
"email": "'${ADMIN_EMAIL}'",
"first_name": "Caseflow",
"last_name": "Admin",
"password": "'${ADMIN_PASSWORD}'"
},
"prefs": {
"allow_tracking": false,
"site_name": "Caseflow"
}
}' | jq -r '.id')

echo "Logging in as admin"
ADMIN_SESSION_ID=$(curl -s -X POST -H \
"Content-type: application/json" http://localhost:3002/api/session \
-d '{"username": "'${ADMIN_EMAIL}'", "password": "'${ADMIN_PASSWORD}'"}' \
| jq -r '.id')

echo "Getting Sample Database ID"
SAMPLE_DB_ID=$(curl -X GET http://localhost:3002/api/database -H "X-Metabase-Session: ${ADMIN_SESSION_ID}" \
| jq '.data[0].id')

echo "Deleting Sample Database"
curl -X DELETE http://localhost:3002/api/database/${SAMPLE_DB_ID} -H "X-Metabase-Session: ${ADMIN_SESSION_ID}"

echo "Creating Caseflow Database connection"
curl -X POST http://localhost:3002/api/database \
-H "Content-type: application/json" \
-H "X-Metabase-Session: ${ADMIN_SESSION_ID}" \
-d '{
"engine": "postgres",
"name": "Caseflow DB",
"details": {
"host": "'${CASEFLOW_HOST}'", "port":"5432", "db": "caseflow_certification_development", "user": "postgres", "password": "postgres"
}
}'

echo -e "\nCreating VACOLS Database connection"
curl -X POST http://localhost:3002/api/database \
-H "Content-type: application/json" \
-H "X-Metabase-Session: ${ADMIN_SESSION_ID}" \
-d '{
"engine": "oracle",
"name": "VACOLS",
"details": {
"host": "'${VACOLS_HOST}'", "port": "1521", "sid": "BVAP", "name": "VACOLS_DEV", "user": "VACOLS_DEV", "password": "VACOLS_DEV"
}
}'

echo -e "\n👥 Creating a basic user: "
curl -s "http://localhost:3002/api/user" \
-H 'Content-Type: application/json' \
-H "X-Metabase-Session: ${ADMIN_SESSION_ID}" \
-d '{"first_name": "Caseflow", "last_name": "User", "email": "'${USER_EMAIL}'", "login_attributes": {"region_filter": "WA"}, "password":"'${USER_PASSWORD}'"}'

echo -e "\nMetabase setup complete!"
90 changes: 90 additions & 0 deletions metabase/metabase_api_script_demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/sh

[email protected]
ADMIN_PASSWORD=caseflow1
[email protected]
USER_PASSWORD=caseflow1

CASEFLOW_HOST=appeals-db
# The Metabase port needs to be 3000 because this will run in the appeals-app container in AWS and the port mapping
# in docker-compose is for the host only
METABASE_HOST=appeals-metabase
METABASE_PORT=3000
VACOLS_HOST=VACOLS_DB-development

echo "Installing JQ"
apt-get update
apt-get install -y jq

echo "Waiting for Metabase to start"
while (! curl -s -m 5 http://${METABASE_HOST}:${METABASE_PORT}/api/session/properties -o /dev/null); do sleep 5; done

echo "Creating admin user"

SETUP_TOKEN=$(curl -s -m 5 -X GET \
-H "Content-Type: application/json" \
http://${METABASE_HOST}:${METABASE_PORT}/api/session/properties \
| jq -r '.["setup-token"]'
)

MB_TOKEN=$(curl -s -X POST \
-H "Content-type: application/json" \
http://${METABASE_HOST}:${METABASE_PORT}/api/setup \
-d '{
"token": "'${SETUP_TOKEN}'",
"user": {
"email": "'${ADMIN_EMAIL}'",
"first_name": "Caseflow",
"last_name": "Admin",
"password": "'${ADMIN_PASSWORD}'"
},
"prefs": {
"allow_tracking": false,
"site_name": "Caseflow"
}
}' | jq -r '.id')

echo "Logging in as admin"
ADMIN_SESSION_ID=$(curl -s -X POST -H \
"Content-type: application/json" http://${METABASE_HOST}:${METABASE_PORT}/api/session \
-d '{"username": "'${ADMIN_EMAIL}'", "password": "'${ADMIN_PASSWORD}'"}' \
| jq -r '.id')

echo "Getting Sample Database ID"
SAMPLE_DB_ID=$(curl -X GET http://${METABASE_HOST}:${METABASE_PORT}/api/database -H "X-Metabase-Session: ${ADMIN_SESSION_ID}" \
| jq '.data[0].id')

echo "Deleting Sample Database"
curl -X DELETE http://${METABASE_HOST}:${METABASE_PORT}/api/database/${SAMPLE_DB_ID} -H "X-Metabase-Session: ${ADMIN_SESSION_ID}"

echo "Creating Caseflow Database connection"
curl -X POST http://${METABASE_HOST}:${METABASE_PORT}/api/database \
-H "Content-type: application/json" \
-H "X-Metabase-Session: ${ADMIN_SESSION_ID}" \
-d '{
"engine": "postgres",
"name": "Caseflow DB",
"details": {
"host": "'${CASEFLOW_HOST}'", "port":"5432", "db": "caseflow_certification_development", "user": "postgres", "password": "postgres"
}
}'

echo -e "\nCreating VACOLS Database connection"
curl -X POST http://${METABASE_HOST}:${METABASE_PORT}/api/database \
-H "Content-type: application/json" \
-H "X-Metabase-Session: ${ADMIN_SESSION_ID}" \
-d '{
"engine": "oracle",
"name": "VACOLS",
"details": {
"host": "'${VACOLS_HOST}'", "port": "1521", "sid": "BVAP", "name": "VACOLS_DEV", "user": "VACOLS_DEV", "password": "VACOLS_DEV"
}
}'

echo -e "\nCreating a basic user: "
curl -s "http://${METABASE_HOST}:${METABASE_PORT}/api/user" \
-H 'Content-Type: application/json' \
-H "X-Metabase-Session: ${ADMIN_SESSION_ID}" \
-d '{"first_name": "Caseflow", "last_name": "User", "email": "'${USER_EMAIL}'", "login_attributes": {"region_filter": "WA"}, "password":"'${USER_PASSWORD}'"}'

echo -e "\nMetabase setup complete!"
Loading