# Seed or API calls to create test users

**URL:** <https://meta.discourse.org/t/seed-or-api-calls-to-create-test-users/126025>\
**Category:** Development\
**Created:** [August 17, 2019, 2:13am UTC](https://meta.discourse.org/t/seed-or-api-calls-to-create-test-users/126025 "2019-08-17T02:13:06Z")\
**Posts on this page:** 7\
**Page:** 1

## AI-generated summary

The discussion revolves around creating test users in a local Discourse instance running on Bitnami Docker for API testing purposes. [alank](/t/-/126025/1) seeks a way to seed multiple users for testing search functionality, noting that the default instance only has one user. While the API documentation doesn't cover user creation, [fzngagan](/t/-/126025/2) suggests using the `enter app` command, which isn't available in the Bitnami setup. [alank](/t/-/126025/3) attempts to run `bundle exec rake admin:create` but encounters a `byebug` load error. [csmu](/t/-/126025/4) questions why Bitnami is used instead of the official Discourse install. [alank](/t/-/126025/5) explains the preference for `docker-compose` for managing multiple services. Finally, [alank](/t/-/126025/6) resolves the issue by accessing the container via `docker exec`, setting `RAILS_ENV=production`, and running the rake task to create users. [alank](/t/-/126025/7) adds a note that the environment variable setting doesn't affect logging, though further testing is needed.

<div class="post-metadata">

**Author:** ![alank](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@alank](https://meta.discourse.org/u/alank)\
**Post date:** [August 17, 2019, 2:13am UTC](https://meta.discourse.org/t/seed-or-api-calls-to-create-test-users/126025/1 "2019-08-17T02:13:06Z")

</div>

In my development and testing I’m running a Discourse instance (Docker Discourse from Bitnami) and it fulfills most of my API testing for our API service which talks to Discourse, however I now need to test search using `/u/search/users.json?term=and` and would like to seed a few users into this local Discourse test service. By default it only has one user with the name of “user”.

The API documentation doesn’t seem to explain API calls to do this, that would be easy, Is there something I’m missing where I can simply create multiple users for testing this?

Also to note, I’ve built manual requests to our live paid Discourse service, and this works, but I’d like to test against our development/test instance and for that I need more test users.

Thanks.

---

<div class="post-metadata">

**Author:** ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)\
**Post date:** [August 17, 2019, 3:58am UTC](https://meta.discourse.org/t/seed-or-api-calls-to-create-test-users/126025/2 "2019-08-17T03:58:05Z")

</div>

Does Bitnami allow you to access command line of the discourse setup folder?

if yes, then check this out

> [@Adding new user when outgoing email has been globally disabled](https://meta.discourse.org/t/adding-new-user-when-outgoing-email-has-been-globally-disabled/123328):
>
> Hi, We have a test site with the email globally disabled, this test site has an old copy of the production site so we don’t want to send any emails from this one. Is there any way to add a new user to our test site which does not involve emailing for confirmation of details? Thanks

---

<div class="post-metadata">

**Author:** ![alank](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@alank](https://meta.discourse.org/u/alank)\
**Post date:** [August 19, 2019, 10:45am UTC](https://meta.discourse.org/t/seed-or-api-calls-to-create-test-users/126025/3 "2019-08-19T10:45:46Z")

</div>

Thanks @fzngagan , unfortunately the Bitnami Discourse does not have Launcher installed, what exactly does `enter app` do, I thought I could just run `bundle exec rake admin:create` but this returns…

```plaintext
rake aborted!
LoadError: cannot load such file -- byebug
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:82:in `require'
/opt/bitnami/discourse/config/application.rb:37:in `<top (required)>'
/opt/bitnami/discourse/Rakefile:5:in `require'
/opt/bitnami/discourse/Rakefile:5:in `<top (required)>'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/opt/bitnami/ruby/bin/bundle:23:in `load'
/opt/bitnami/ruby/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)

```

So this looked promising but I’m back at square one. ☹

---

<div class="post-metadata">

**Author:** ![csmu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/csmu/32/124581_2.png) [@csmu](https://meta.discourse.org/u/csmu)\
**Post date:** [August 19, 2019, 10:58am UTC](https://meta.discourse.org/t/seed-or-api-calls-to-create-test-users/126025/4 "2019-08-19T10:58:52Z")

</div>

> [@alank](#):
>
> Bitnami Discourse does not have Launcher

Could you use the supported official Discourse install?

---

<div class="post-metadata">

**Author:** ![alank](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@alank](https://meta.discourse.org/u/alank)\
**Post date:** [August 19, 2019, 11:30am UTC](https://meta.discourse.org/t/seed-or-api-calls-to-create-test-users/126025/5 "2019-08-19T11:30:59Z")

</div>

We have a number of services required in our development environment and prefer to start everything up (along with Discourse and all its modules) as well as defining/controlling networking between all the services with one command `docker-compose up` as well as bringing everything `down` again. This avoids the additional step of adding launcher to a new install of our development.

---

<div class="post-metadata">

**Author:** ![alank](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@alank](https://meta.discourse.org/u/alank)\
**Post date:** [August 19, 2019, 11:46am UTC](https://meta.discourse.org/t/seed-or-api-calls-to-create-test-users/126025/6 "2019-08-19T11:46:18Z")

</div>

OK, resolved, for those using a bitnami Discourse docker-compose (Docker) install for development, here are the steps I used (with guidance from what @fzngagan pointed out)

`> docker exec -it <your container name> /bin/bash`

In the container…

`> export RAILS_ENV=production`

_I’m not sure what impact this will have on logging and maybe I should have tried `=dev or development`.. so something for you guys to report but I’m on a rush, sorry_

`> bundle exec rake admin:create`

_Answer the questions, password must adhere to Discourse rules or else the script starts from the beginning again_

Note: No need for ./Launcher as stated in the link that @fzngagan stated above.

It’s unfortunate that this isn’t available via the API if Discourse was set to a Dev or Test env as this would greatly simplify testing and development for API services that want to use, however I’ll live with the command line in the Docker instance for now.

---

<div class="post-metadata">

**Author:** ![alank](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@alank](https://meta.discourse.org/u/alank)\
**Post date:** [August 19, 2019, 11:50am UTC](https://meta.discourse.org/t/seed-or-api-calls-to-create-test-users/126025/7 "2019-08-19T11:50:36Z")

</div>

Additional note, `> export RAILS_ENV=production` (setting to `production`) appears to have no impact on Discourse logging info, however I did not stop/start my docker-compose after that change, so might have to delete the env variable or set to `development` or ‘dev’ or whatever.
