Skip to content
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
21 changes: 21 additions & 0 deletions .github/workflows/check_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build EE2 Docker Image

on:
pull_request

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push
uses: docker/build-push-action@v6
with:
push: false
tags: ee2/test:test
Comment on lines +10 to +21

@Xiangs18 Xiangs18 Aug 5, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Is QEMU setup necessary?
  2. format each step with spacing to make it easier to read. (optional)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

26 changes: 16 additions & 10 deletions .github/workflows/ee2-tests.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# This workflow will install Python dependencies, run tests and lint
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

# To ssh into this build add the following:
#- name: Start SSH session
# uses: luchihoratiu/debug-via-ssh@main
# with:
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
# SSH_PASS: ${{ secrets.SSH_PASS }}

name: Execution Engine 2 Test Suite

Expand Down Expand Up @@ -50,9 +44,17 @@ jobs:
path: "./test"



Build_and_Run_Tests_and_CodeCov:
name: Build and Run Tests and CodeCov
runs-on: ubuntu-latest
strategy:
matrix:
mongo-config:
- version: "7.0"
init-path: "./test/dockerfiles/mongo/docker-entrypoint-initdb.d-7.0/"
- version: "3.6"
init-path: "./test/dockerfiles/mongo/docker-entrypoint-initdb.d-3.6/"
steps:
- name: Check out source repository
uses: actions/checkout@v4
Expand All @@ -64,12 +66,16 @@ jobs:
run: |
pip install -r requirements.txt
git clone https://github.com/kbase/jars /opt/jars
- name: Build Docker Image
- name: Set MongoDB Version and Init Path
run: |
docker build . -t execution_engine2:test
- name: Run Tests
echo "MONGO_VERSION=${{ matrix.mongo-config.version }}" >> $GITHUB_ENV
echo "INIT_PATH=${{ matrix.mongo-config.init-path }}" >> $GITHUB_ENV
- name: Start Services and Run Tests
run: |
docker compose up -d
cp test/env/test.travis.env test.env
make test-coverage
codecov
codecov --token="${{ secrets.CODECOV_TOKEN }}"
- name: Cleanup
run: |
docker compose down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ setup-database:
test-coverage:
# Set up travis user in mongo
@echo "Run tests for $(TESTS)"
PYTHONPATH=.:lib:test pytest --cov-report=xml --cov lib/execution_engine2/ --verbose $(TESTS)
PYTHONPATH=.:lib:test pytest --cov-report=xml --cov-report=term --cov lib/execution_engine2/ --verbose $(TESTS)

build-condor-test-image:
cd test/dockerfiles/condor && echo `pwd` && docker build -f Dockerfile . -t $(CONDOR_DOCKER_IMAGE_TAG_NAME)
Expand Down
109 changes: 56 additions & 53 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,58 @@ version: "3.1"

services:

# For Local Dev
# Requires a ` docker build . -t execution_engine2:test `
# Requires a ` make database `
ee2:
image: execution_engine2:test
command:
- "-poll"
- "-template"
- "/kb/module/build/templates/condor_config.templ:/etc/condor/condor_config"
- "-template"
- "/kb/module/test/deploy.cfg:/kb/module/deploy.cfg"
- "-timeout"
- "120s"
- "-wait"
- "tcp://mongodb:27017"
- "-stdout"
- "/kb/deployment/jettybase/logs/request.log"
- "./scripts/entrypoint.sh"
entrypoint: [ "dockerize" ]
depends_on: ["mongodb","condor"]
environment:
- POOL_PASSWORD=weakpassword
env_file: test/deploy.cfg
volumes:
- ./:/ee2

ee2_with_ssh:
image: execution_engine2:test
command:
- "-poll"
- "-template"
- "/kb/module/build/templates/condor_config.templ:/etc/condor/condor_config"
- "-template"
- "/kb/module/build/templates/deploy.docker.cfg.templ:/kb/module/deploy.cfg"
- "-timeout"
- "120s"
- "-wait"
- "tcp://mongodb:27017"
- "-stdout"
- "/kb/deployment/jettybase/logs/request.log"
- "./scripts/entrypoint.sh"
entrypoint: [ "dockerize" ]
depends_on: ["mongodb","condor"]
environment:
- POOL_PASSWORD=weakpassword
- LOCAL_DEV=1
- KB_DEPLOYMENT_CONFIG=/kb/module/deploy.cfg
env_file: test/deploy.cfg
ports: ["23:22","5678:5678"]
volumes:
- ./:/ee2
- /Users:/Users
# ee2:
# image: execution_engine2:test
# command:
# - "-poll"
# - "-template"
# - "/kb/module/build/templates/condor_config.templ:/etc/condor/condor_config"
# - "-template"
# - "/kb/module/test/deploy.cfg:/kb/module/deploy.cfg"
# - "-timeout"
# - "120s"
# - "-wait"
# - "tcp://mongodb:27017"
# - "-stdout"
# - "/kb/deployment/jettybase/logs/request.log"
# - "./scripts/entrypoint.sh"
# entrypoint: [ "dockerize" ]
# depends_on: ["mongodb","condor"]
# environment:
# - POOL_PASSWORD=weakpassword
# env_file: test/deploy.cfg
# volumes:
# - ./:/ee2
#
# ee2_with_ssh:
# image: execution_engine2:test
# command:
# - "-poll"
# - "-template"
# - "/kb/module/build/templates/condor_config.templ:/etc/condor/condor_config"
# - "-template"
# - "/kb/module/build/templates/deploy.docker.cfg.templ:/kb/module/deploy.cfg"
# - "-timeout"
# - "120s"
# - "-wait"
# - "tcp://mongodb:27017"
# - "-stdout"
# - "/kb/deployment/jettybase/logs/request.log"
# - "./scripts/entrypoint.sh"
# entrypoint: [ "dockerize" ]
# depends_on: ["mongodb","condor"]
# environment:
# - POOL_PASSWORD=weakpassword
# - LOCAL_DEV=1
# - KB_DEPLOYMENT_CONFIG=/kb/module/deploy.cfg
# env_file: test/deploy.cfg
# ports: ["23:22","5678:5678"]
# volumes:
# - ./:/ee2
# - /Users:/Users



Expand Down Expand Up @@ -146,13 +147,15 @@ services:
ZOOKEEPER_SYNC_LIMIT: 2docker-compose rm
ZOOKEEPER_SERVERS: zookeeper:12888:13888


mongodb:
image: mongo:7.0
image: mongo:${MONGO_VERSION:-7.0} # Use 7.0 as the default if MONGO_VERSION is not set
environment:
# provide your credentials here
- MONGO_INITDB_ROOT_USERNAME=travis
- MONGO_INITDB_ROOT_PASSWORD=travis
- MONGO_INITDB_DATABASE=ee2
ports: ["27018:27017","27017:27017"]
ports:
- "27018:27017"
- "27017:27017"
volumes:
- "./test/dockerfiles/mongo/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/"
- ${INIT_PATH:-./test/dockerfiles/mongo/docker-entrypoint-initdb.d-7.0/}:/docker-entrypoint-initdb.d/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

INIT_PATH got mapped from the host machine into the container. Where are the files inside docker-entrypoint-initdb.d used?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This allows you to use the docker-compose both locally and in github actions. In github actions, we set the INIT_PATH in the action. These files are used by mongo to create the proper users for testing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
print("Adding travis username to ee2 database")

// db.auth('travis', 'travis') This no longer works on Mongo7


print("Adding travis username to ee2 database for mongo 3.6")
db.auth('travis', 'travis')
db = db.getSiblingDB('ee2')

db.createUser(
{
user: "travis",
Expand All @@ -16,4 +12,4 @@ db.createUser(
}
]
}
);
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
print("Adding travis username to ee2 database for mongo 7.0")
db = db.getSiblingDB('ee2')

@Xiangs18 Xiangs18 Aug 5, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't need this line db.auth('travis', 'travis') on mongo7

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Correct, it causes the init script to fail on mongo7

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Otherwise, I would be able to use the same script for mongo 3.6 and mongo 7, but I cannot. That's the whole point of using 2 different scripts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

db.createUser(
{
user: "travis",
pwd: "travis",
roles: [
{
role: "dbOwner",
db: "ee2"
}
]
}
);