Seed or API calls to create test users

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.


1 Like

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

if yes, then check this out


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…

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. :frowning:

Could you use the supported official Discourse install?

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.

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.

1 Like

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.

1 Like