Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ auth.env
api-gateway.env
syncing-server-js.env
syncing-server.env
mock-event-publisher.env
codeqldb

packages/components/tmp
44 changes: 42 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,45 @@ services:
networks:
- snjs

sns:
image: s12v/sns
expose:
- 9911
volumes:
- ./docker/sns.json:/etc/sns/db.json
- ./wait-for.sh:/etc/scripts/wait-for.sh
restart: unless-stopped
entrypoint: [
"./etc/scripts/wait-for.sh", "sqs", "9324",
"java", "-jar", "/sns.jar"
]
networks:
snjs:
aliases:
- sns

sqs:
image: s12v/elasticmq
expose:
- 9324
volumes:
- ./docker/sqs.conf:/etc/elasticmq/elasticmq.conf
restart: unless-stopped
networks:
- snjs

mock-event-publisher:
image: standardnotes/mock-event-publisher:1.0.4
entrypoint: [
"./wait-for.sh", "sns", "9911",
"./docker/entrypoint.sh", "start-web"
]
ports:
- 3124:3000
env_file: docker/mock-event-publisher.env
networks:
- snjs

cache:
image: redis:6.0-alpine
expose:
Expand Down Expand Up @@ -72,7 +111,7 @@ services:
- snjs

auth:
image: standardnotes/auth:1.33.0
image: standardnotes/auth:1.35.3
depends_on:
- syncing-server-js
entrypoint: [
Expand All @@ -84,11 +123,12 @@ services:
- snjs

auth-worker:
image: standardnotes/auth:1.33.0
image: standardnotes/auth:1.35.3
depends_on:
- auth
entrypoint: [
"./wait-for.sh", "auth", "3000",
"./wait-for.sh", "sqs", "9324",
"./docker/entrypoint.sh", "start-worker"
]
env_file: docker/auth.env
Expand Down
5 changes: 5 additions & 0 deletions docker/auth.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ FAILED_LOGIN_LOCKOUT=3600
SYNCING_SERVER_URL=http://syncing-server-js:3000

NEW_RELIC_ENABLED=false

SQS_QUEUE_URL="http://sqs:9324/queue/auth"
SQS_AWS_REGION="us-east-1"
SQS_ACCESS_KEY_ID="x"
SQS_SECRET_ACCESS_KEY="x"
9 changes: 9 additions & 0 deletions docker/mock-event-publisher.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
LOG_LEVEL="debug"
NODE_ENV="production"
VERSION="snjs-test"
SNS_TOPIC_ARN="arn:aws:sns:us-east-1:1-2-3:snjs"
SNS_ENDPOINT="http://sns:9911"
SNS_AWS_SECRET_ACCESS_KEY="x"
SNS_AWS_ACCESS_KEY_ID="x"
SNS_AWS_REGION="us-east-1"
NEW_RELIC_ENABLED=false
19 changes: 19 additions & 0 deletions docker/sns.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": 1,
"timestamp": 1465414804110,
"subscriptions": [
{
"arn": "e9126059-9eab-4b37-8194-e0d64dfb2045",
"topicArn": "arn:aws:sns:us-east-1:1-2-3:snjs",
"endpoint": "aws-sqs://auth?amazonSQSEndpoint=http://sqs:9324&accessKey=&secretKey=",
"owner": "",
"protocol": "sqs"
}
],
"topics": [
{
"arn": "arn:aws:sns:us-east-1:1-2-3:snjs",
"name": "snjs"
}
]
}
9 changes: 9 additions & 0 deletions docker/sqs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include classpath("application.conf")

node-address {
host = sqs
}

queues {
auth {}
}
15 changes: 15 additions & 0 deletions packages/snjs/mocha/lib/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export function getDefaultHost() {
return 'http://localhost:3123';
}

export function getDefaultMockedEventServiceUrl() {
return 'http://localhost:3124';
}

export function getDefaultWebSocketUrl() {
return 'ws://localhost';
}
Expand All @@ -117,6 +121,17 @@ function getAppVersion() {
return '1.2.3';
}

export async function publishMockedEvent(eventType, eventPayload) {
await fetch({
url: `${getDefaultMockedEventServiceUrl()}/events`,
method: 'post',
body: JSON.stringify({
eventType,
eventPayload
})
})
}

export function createApplication(identifier, environment, platform, host) {
const deviceInterface = new WebDeviceInterface(
setTimeout.bind(window),
Expand Down
3 changes: 2 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function setup {
cp docker/api-gateway.env.sample docker/api-gateway.env
cp docker/auth.env.sample docker/auth.env
cp docker/syncing-server-js.env.sample docker/syncing-server-js.env
cp docker/mock-event-publisher.env.sample docker/mock-event-publisher.env

echo "# Installing project dependecies (Host Machine)"
yarn install --pure-lockfile
Expand Down Expand Up @@ -51,7 +52,7 @@ function startContainers {

function waitForServices {
attempt=0
while [ $attempt -le 60 ]; do
while [ $attempt -le 90 ]; do
attempt=$(( $attempt + 1 ))
echo "# Waiting for all services to be up (attempt: $attempt) ..."
result=$(docker compose -f $COMPOSE_FILE logs api-gateway)
Expand Down