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

Gitlab CI with ava and mongodb memory server #2469

Closed
MaxDesplanches opened this issue Apr 23, 2020 · 1 comment
Closed

Gitlab CI with ava and mongodb memory server #2469

MaxDesplanches opened this issue Apr 23, 2020 · 1 comment

Comments

@MaxDesplanches
Copy link

Hello there,

I am using Gitlab CI to execute ava test. Unfortunately, I got an error in pipeline on test execution:

Setup

api-authorization.js

import _ from 'lodash';
import { MongoMemoryServer } from 'mongodb-memory-server';
import test from 'ava';
import { ForbiddenError } from '@casl/ability';
import errors from '@feathersjs/errors';
import mongo from '../src/lib/mongo';
import app from '../src/apps/api';
import Account from '../src/models/Account';
import Organization from '../src/models/Organization';

let mongoMockServer;

test.before(async (t) => {
  t.log('Trying to launch Mock Mongo DB');
  mongoMockServer = new MongoMemoryServer({
    instance: { port: 27017, dbName: 'gowento' },
  });
  const mongoUri = await mongoMockServer.getConnectionString();
  await mongo.start(mongoUri);
  t.log('Mongo Mock Server launched status: true');

  // load Organization in database
  await Organization.insertMany(fixtures.organizations);

  // load Account in database
  await Account.insertMany(fixtures.accounts);
});

test.after(async () => {
  await Account.remove({ email: { $in: _.map(fixtures.accounts, 'email') } });
  await Organization.remove({
    id: { $in: _.map(fixtures.organizations, 'id') },
  });
});

gitlab-ci.yml

image: node

stages:
  - build
  - test

cache:
  paths:
    - node_modules/

install_dependencies:
  stage: build
  tags:
    - docker
  script:
    - npm run heroku-prebuild --trace-warnings
    - npm install
  artifacts:
    paths:
      - node_modules/

lint:
  stage: test
  tags:
    - docker
  script:
    - npm run lint

test:
  stage: test
  services:
  - redis:latest
  variables:
    REDIS_URL: 'redis://redis:6379'
    MONGODB_URI: 'mongodb://127.0.0.1:27017/gowento'
  tags:
    - docker
  script:
    - ./node_modules/.bin/ava test test/api-authorization.js --verbose

Expected behaviour

All tests passed (works in local with same command from test script)

Actual behaviour

pipeline from gitlab container

67 ℹ info	[Redis Connection: shared bull client] connect 
68 ℹ info	[Redis Connection: shared bull subscriber] connect 
69 ℹ info	[Redis Connection: shared bull util] connect 
70 ℹ info	[Redis Connection: shared bull client] ready 
71 ℹ info	[Redis Connection: shared bull subscriber] ready 
72 ℹ info	[Redis Connection: shared bull util] ready 
73 the options [debug] is not supported
74   Uncaught exception in test/api-authorization.js
75 ℹ info	[Mongoose] connected uri=mongodb://127.0.0.1:27017/g...
76   ✖ test/api-authorization.js exited with a non-zero exit code: 1
77   1 uncaught exception
81 ERROR: Job failed: exit code 1

If you have any ideas, maybe a memory limit ...

thanks you for your advices, even verbose doesn't provide any details :(

Max.

@novemberborn
Copy link
Member

It looks like there was an uncaught exception, though the stack trace doesn't seem available. There are some improvements due to come out in the next release of AVA that could help you.

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants