# Different result depending the container number

**URL:** <https://discuss.circleci.com/t/different-result-depending-the-container-number/10283>\
**Category:** Build Environment\
**Tags:** rspec, parallelism\
**Created:** [February 10, 2017, 9:38am UTC](https://discuss.circleci.com/t/different-result-depending-the-container-number/10283 "2017-02-10T09:38:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpiqueras](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jpiqueras/32/15422_2.png) [@jpiqueras](https://discuss.circleci.com/u/jpiqueras)\
**Post date:** [February 10, 2017, 9:38am UTC](https://discuss.circleci.com/t/different-result-depending-the-container-number/10283/1 "2017-02-10T09:38:27Z")

</div>

I’m testing CircleCI and so far it looks good. But I’m facing a weird problem with parallelisation.

I’m running a build with 2 containers. And using a bash _case_ statement to select which commands (rspec) to run in each container.

The specs executed in container 0 always work. The specs executed in container 1 always fail. If I move the commands from 1 to 0, they work.

Any idea why this might happen? The steps to get there are the same for both containers, I can’t think of a reason why some fail and some doesn’t. Maybe something on the db setup between containers is different?

I’m using a database configuration taken from the first run I did. You can see it below.

circle.yml

```
machine:
  ruby:
    version: 2.2.6
  node:
    version: 4.2.6
  environment:
    RAILS_ENV: test
  services:
    - redis
database:
  override:
    - cp config/database.circle.yml config/database.yml
    - bundle exec rake db:create db:schema:load
test:
  pre:
    - npm run build
  override:
    - bundle exec rubocop -c .rubocop_strict.yml
    - ? |
        case $CIRCLE_NODE_INDEX in
          0)
            COUNTRY=Germany bundle exec rspec ./spec/features/single_country/de/
            COUNTRY=Australia bundle exec rspec ./spec/features/single_country/au/
            ;;
          1)
            COUNTRY=France bundle exec rspec ./spec/features/single_country/fr/
            COUNTRY=UK bundle exec rspec ./spec/features/single_country/uk/
            ;;
        esac
      :
        parallel: true

```

database.circle.yml

```
test:
  adapter: postgresql
  encoding: unicode
  database: circle_ruby_test
  username: ubuntu
  pool: 16
  host: localhost
  port: 5432
```

---

<div class="post-metadata">

**Author:** ![jpiqueras](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jpiqueras/32/15422_2.png) [@jpiqueras](https://discuss.circleci.com/u/jpiqueras)\
**Post date:** [February 10, 2017, 11:15am UTC](https://discuss.circleci.com/t/different-result-depending-the-container-number/10283/2 "2017-02-10T11:15:38Z")

</div>

I just discovered why.  
The npm run build is only being executed in container 0.

![](https://global.discourse-cdn.com/circleci/original/3X/5/e/5e8b4d71ff4c65d1d35b9817b306c1d90431a2d8.png)

The solution is putting the _parallel: true_ to the _npm build_

```
test:
  pre:
    - npm run build:
        parallel: true
```

---

<div class="post-metadata">

**Author:** ![KapilMetacube](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kapilmetacube/32/10093_2.png) [@KapilMetacube](https://discuss.circleci.com/u/KapilMetacube)\
**Post date:** [January 2, 2018, 5:57am UTC](https://discuss.circleci.com/t/different-result-depending-the-container-number/10283/3 "2018-01-02T05:57:02Z")

</div>

Your solution helped in [another issue](https://discuss.circleci.com/t/test-cases-fails-if-parallelism-is-used-passes-otherwise/18828) I was encountering due to parallelism.

The problem I think is the circlelci UI that confuses the user, as the command looks like to have been executed on all containers but actually ran on only the first.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:39am UTC](https://discuss.circleci.com/t/different-result-depending-the-container-number/10283/4 "2018-06-18T11:39:09Z")

</div>

Closed on June 18, 2018, 11:39am UTC


