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

More integration tests, New github action to run integration tests #602

Draft
wants to merge 24 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7b2e671
datasource upload, nonfunctional upload
NaderRNA Oct 2, 2024
2af7068
Merge branch 'develop' into more-integration-tests
NaderRNA Oct 2, 2024
d50ede7
file successfully uploads, test not completed
NaderRNA Oct 3, 2024
8bdca7b
package-lock.json changes
NaderRNA Oct 3, 2024
a93a890
successful file upload test, adding agent tests
NaderRNA Oct 3, 2024
195f8a1
lint
NaderRNA Oct 3, 2024
51d423e
wip
NaderRNA Oct 3, 2024
4176a8f
Merge branch 'develop' into more-integration-tests
tomlynchRNA Oct 3, 2024
f404bad
modifying all tests to delete any objects created within the test to …
NaderRNA Oct 4, 2024
ca1115c
Merge branch 'develop' into more-integration-tests
NaderRNA Oct 4, 2024
e183983
Merge branch 'develop' into more-integration-tests
NaderRNA Oct 7, 2024
dca9d06
Merge branch 'more-integration-tests' of github.com:rnadigital/agentc…
NaderRNA Oct 7, 2024
1174085
modifying .env.example to work with integration tests, including scri…
NaderRNA Oct 8, 2024
86e5301
Create webapp-integration-tests.yml
NaderRNA Oct 8, 2024
9271db3
fixing merge conflicts
NaderRNA Oct 8, 2024
01c6538
Update webapp-integration-tests.yml
NaderRNA Oct 8, 2024
98a0a6d
adding .env.example to vector-db-proxy
NaderRNA Oct 8, 2024
084341e
Merge branch 'more-integration-tests' of github.com:rnadigital/agentc…
NaderRNA Oct 8, 2024
935d182
fixing terminal issue in github action
NaderRNA Oct 8, 2024
e91a834
adding firefox support to action
NaderRNA Oct 8, 2024
f4d29d9
adding install.sh back into the action
NaderRNA Oct 8, 2024
42b1169
fixing dockercompose issues
NaderRNA Oct 8, 2024
44a4e47
slightly modifying test file before merging develop into this branch
NaderRNA Oct 10, 2024
4a5ddb6
adding another agent test
NaderRNA Oct 11, 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
43 changes: 43 additions & 0 deletions .github/workflows/webapp-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

name: Run Webapp Integration Tests

on:
pull_request:
branches: [ "develop" ]

jobs:
integration-tests:
name: Build app and run integration tests
runs-on: ubuntu-latest
env:
TERM: xterm
permissions:
contents: read
security-events: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup firefox
id: setup-firefox
uses: browser-actions/setup-firefox@v1

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Set environment variables
run: ./setemptyenv.sh

- name: Install webapp dependencies
working-directory: ./webapp
run: npm install

- name: run ./install.sh
run: ./install.sh

- name: run integration tests
working-directory: ./webapp
run: npm run test:integration
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
container_name: unstructured-api
environment:
- PORT=9500
image: localhost:5000/unstructured-api
image: localhost:9500/unstructured-api

docker_rabbitmq:
image: rabbitmq:3.13.1-management
Expand Down
37 changes: 37 additions & 0 deletions setemptyenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash


# Function to copy .env.example to .env
copy_env_example() {
# Check if .env.example exists
if [ ! -f ".env.example" ]; then
echo ".env.example file does not exist."
exit 1
fi

# Copy contents of .env.example to .env
cp .env.example .env
echo ".env file has been created with the contents of .env.example."
}

# Navigate to the ./webapp directory
cd ./webapp || {
echo "Failed to navigate to ./webapp. Directory does not exist.";
exit 1;
}

copy_env_example

cd ../agent-backend || {
echo "Failed to navigate to ../agent-backend. Directory may not exist";
exit 1;
}

copy_env_example

cd ../vector-db-proxy || {
echo "Failed to navigate to ../vector-db-proxy. Directory may not exist";
exit 1;
}

copy_env_example
21 changes: 21 additions & 0 deletions vector-db-proxy/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
HOST=0.0.0.0
PORT=9001
MONGO_URI=mongodb://docker_mongo:27017
MONGO_DB_NAME=test
RABBITMQ_HOST=docker_rabbitmq
RABBITMQ_PORT=5672
RABBITMQ_STREAM=streaming
RABBITMQ_EXCHANGE=agentcloud
RABBITMQ_ROUTING_KEY=key
RABBITMQ_USERNAME=guest
RABBITMQ_PASSWORD=guest
QDRANT_URI=http://qdrant:6334
QDRANT_HOST=http://qdrant
QDRANT_PORT=6334
REDIS_HOST=docker_redis
REDIS_PORT=6379
WEBAPP_HOST=webapp_next
THREAD_PERCENTAGE_UTILISATION=0.8
USE_GPU=false
LOGGING_LEVEL=warn
UNSTRUCTURED_API_URL=http://unstructured-api:9500/general/v0/general
2 changes: 2 additions & 0 deletions webapp/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ STRIPE_ADDON_USERS_PRODUCT_ID=
STRIPE_ADDON_STORAGE_PRODUCT_ID=
STRIPE_WEBHOOK_SECRET=
STRIPE_ACCOUNT_SECRET=
SKIP_EMAIL=1
SKIP_STRIPE=1
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
WEBAPP_TEST_BASE_URL=http://localhost:3000
NEXT_PUBLIC_LOCAL_UNSTRUCTURED=1
2 changes: 1 addition & 1 deletion webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webapp/src/lib/middleware/auth/checksession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { dynamicResponse } from '@dr';

export default function checkSession(req, res, next) {
if (!res.locals.account?._id && !res.locals.isAgentBackend) {
// console.log("checkSession, reslocals: ", res.locals);
console.log('checkSession, reslocals: ', res.locals);
if (res.locals.isSocket) {
return res?.locals?.socket?.disconnect();
} else {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/lib/middleware/auth/fetchsession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ const log = debug('webapp:session');
export default async function fetchSession(req, res, next) {
// log('req.session:', req.session);
if (req.session && (req.session.accountId || req.session.passport?.user)) {
log('req.session.account', req.session.accountId);
let account: Account;
if (req.session.accountId) {
account = await getAccountById(req.session.accountId);
} else if (req.session.passport?.user) {
const { oauthId, provider } = req.session.passport?.user;
account = await getAccountByOAuthOrEmail(oauthId, provider, null);
}
// log('account:', account);
log('account:', account);
if (account) {
res.locals.account = {
_id: account._id.toString(),
Expand Down
10 changes: 5 additions & 5 deletions webapp/src/test/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ beforeAll(async () => {

describe('account tests', () => {

test('register new accounts', async () => {
test.only('register new accounts', async () => {
let response = await fetch(`${process.env.WEBAPP_TEST_BASE_URL}/forms/account/register`, {
method: 'POST',
headers: {
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('account tests', () => {
await db.db().collection('accounts').deleteMany({ email: accountDetails.account3_email }); //delete these accounts so we can stress test logins in the next test
}, 60 * SECONDS); //extended timeout due to multiple account creations

test('stress test registration with many accounts', async () => {
test.only('stress test registration with many accounts', async () => {
const accounts = [
{ name: accountDetails.account1_name, email: accountDetails.account1_email, password: accountDetails.account1_password },
{ name: accountDetails.account2_name, email: accountDetails.account2_email, password: accountDetails.account2_password },
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('account tests', () => {


//TODO: refactor this to do it with a loop
test('login as new users - 11 logins', async () => {
test.only('login as new users - 11 logins', async () => {
let response = await fetch(`${process.env.WEBAPP_TEST_BASE_URL}/forms/account/login`, {
method: 'POST',
headers: {
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('account tests', () => {
}, 60 * SECONDS); // extended timeout due to multiple account logins


test('get account', async () => {
test.only('get account', async () => {
const url = `${process.env.WEBAPP_TEST_BASE_URL}/account.json`;
const accounts = [
{ email: accountDetails.account1_email, sessionCookie: sessionCookie1 },
Expand Down Expand Up @@ -353,7 +353,7 @@ describe('account tests', () => {
//test with valid token??

//sets the role to prevent redirects to onboarding in further tests
test('set role - onboarding', async () => {
test.only('set role - onboarding', async () => {
const accounts = [
accountDetails.account1_email,
accountDetails.account2_email,
Expand Down
Loading
Loading