Getting CircleCICucumberFormatter::CircleCIJson error when upgrading Cucumber

I’m attempting to upgrade our Circle project to use 2.0 - following the docs I generated a first pass at a 2.0 file with the config-translation endpoint, and made a couple of slight changes to try and fit it to our project (Current file content is at the bottom of this post).

I’m having an issue around the database:
either a) I include a specific db image in the config.yml as below, ie including this section:

docker:
    - image: circleci/ruby:2.3-jessie-node-browsers
    - image: circleci/postgres:9.6-alpine-postgis
      command: /sbin/init

and then I get the following error:

`init: must be run as PID 1

 Exited with code 1`

(and I just realise this also gets the error in b, next)

or b) I comment out the line which as far as I understand from the docs isn’t strictly essential and when Circle runs the line bundle exec rake db:create db:schema:load --trace,

I get a bunch of failure messages, the key part of which seems to be these lines:

`Couldn't create database for {"username"=>"ubuntu", 
"database"=>"circle_ruby_test", "adapter"=>"postgresql", 
"encoding"=>"unicode", "pool"=>5, "host"=>"localhost"}
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config 
** Execute db:schema:load
-- enable_extension("plpgsql")
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

Since Circle 1.0 is being discontinued, we obviously need to fix this asap. Any advice?

Thanks!,

Sasha

(new config.yml follows)

version: 2
jobs:
  build:
    working_directory: ~/FoundersPledge/founders-pledge
    parallelism: 1
    shell: /bin/bash --login
    environment:
      CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
      CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
    docker:
    - image: circleci/ruby:2.3-jessie-node-browsers
    - image: circleci/postgres:9.6-alpine-postgis
    steps:
    - checkout
    - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
    - restore_cache:
        keys:
        - v1-dep-{{ .Branch }}-
        - v1-dep-master-
        - v1-dep-
    - run: echo -e "export RAILS_ENV=test\nexport RACK_ENV=test" >> $BASH_ENV
    - run: 'bundle check --path=vendor/bundle || bundle install --path=vendor/bundle
        --jobs=4 --retry=3 '
    - run: curl -Ls https://install.convox.com/linux.zip > convox.zip
    - run: sudo unzip convox.zip -d /usr/local/bin
    - save_cache:
        key: v1-dep-{{ .Branch }}-{{ epoch }}
        paths:
        - vendor/bundle
        - ~/virtualenvs
        - ~/.m2
        - ~/.ivy2
        - ~/.bundle
        - ~/.go_workspace
        - ~/.gradle
        - ~/.cache/bower
    - run: |-
        mkdir -p config && echo 'test:
          username: ubuntu
          database: circle_ruby_test
          adapter: postgresql
          encoding: unicode
          pool: 5
          host: localhost
        ' > config/database.yml
    - run:
        command: bundle exec rake db:create db:schema:load --trace
        environment:
          RAILS_ENV: test
          RACK_ENV: test
    - run: mkdir -p $CIRCLE_TEST_REPORTS/rspec
    - run:
        command: bundle exec rspec --color --require spec_helper --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec/rspec.xml --format progress spec
        environment:
          RAILS_ENV: test
          RACK_ENV: test
    - run: mkdir -p $CIRCLE_TEST_REPORTS/cucumber
    - run:
        command: 'bundle exec cucumber --format json --out $CIRCLE_TEST_REPORTS/cucumber/cucumber.cucumber '
        environment:
          RAILS_ENV: test
          RACK_ENV: test
    - run: bundle exec bin/circle
    - store_test_results:
        path: /tmp/circleci-test-results
    - store_artifacts:
        path: /tmp/circleci-artifacts
    - store_artifacts:
        path: /tmp/circleci-test-results

Sorry, done

OK, why are you wanting to run /sbin/init as a command? It’s probably already run as an entrypoint. What sub-problem are you actually trying to solve?

(The docker keys and items below it also need formatting, in your second para. I am assuming the command is for your postgres:9.6-alpine-postgis container, but this is not entirely clear. Would you amend this as well?)

OK, why are you wanting to run /sbin/init as a command? It’s probably already run as an entrypoint. What sub-problem are you actually trying to solve?

That was autogenerated from our old config.yml by the translation endpoint along with a number of other lines whose purpose I wasn’t sure of, and I didn’t see anything in the ‘Migrating from 1.0 to 2.0’ doc to suggest I should delete it. (I just tried removing it, but it hasn’t changed the error)

I’ve cleaned up the docker key in para 2 to make the (original) formatting clearer

Yeah, get rid of that - I assume from your later YAML that you have done so anyway.

The next two things I would try are:

  • Search this forum for how to supply a default username and password for the root account to the PostgreSQL image. Ping me if you cannot find it, but please do a thorough search first. Add these and try again.
  • If that does not help, use the SSH feature on a failing build to get a console onto the first image. CircleCI merges networking stacks between containers, so your PostgreSQL database ought to appear on localhost. Install a PostgreSQL console client (temporarily) in your SSH session and play around to see if the server is still alive.

Then, if that fails, report your findings back here.

1 Like

Ok, I’ve got it to work using the following image config:

- image: circleci/ruby:2.3-jessie-node-browsers
  environment:
    PGHOST: 127.0.0.1
    PGUSER: ubuntu
    RAILS_ENV: test
    POSTGRES_USER: ubuntu
- image: circleci/postgres:9.6.9-alpine-ram
  environment:
    POSTGRES_USER: ubuntu
    POSTGRES_DB: circleci_test
    POSTGRES_PASSWORD: ""

Which I cobbled together with some trial and error from these threads.

I’m still not entirely sure why it works, though - eg, why the user needs to be called ‘ubuntu’ (in local development the user name and password would be blank), and whether this is explained in the docs somewhere. I retrospectively found it referenced here, but I’m still not sure why (btw should that example be nested under the ‘Example CircleCI Configuration for a Rails App With structure.sql’ section? As far as I understand, they’re separate sets of example config, which look inconsistent with each other)

Obviously no great urgency now it’s working, but if you can find time to explain/point me to the docs I should have read, I’d be grateful.

Cheers,

Sasha

I don’t know, I’m afraid; I’ve not needed to use PostgreSQL on CircleCI. Were I to need to, and got stuck with the pre-rolled image, I’d probably create my own image anyway.

I am pleased you figured it out. :smiley:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.