Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,30 @@ Usage
This will launch the container in interactive mode, and mount the dir
with the clones to the container's `/opt/tracker`.

6. Create a new empty instance of `python-dev` using:

```
rd-admin init
```

7. Run it using:
6. Every time the container is run, the tracker is initialized and 3
users are created. You can then run the tracker with:

```
rd-start
```

8. Your local instance of bugs.python.org should be available under
7. Your local instance of bugs.python.org should be available at
http://localhost:9999
On top of the two default users (`admin` and `anonymous`),
3 additional users are also available:
* `user`: a regular user
* `developer`: a developer (triager) that signed the cla
* `coordinator`: a coordinator and committer that signed the cla

You can login as any of these 3 users using `pass` as password.


Notes
-----
* Every time you stop the container, all the users and issues you
created will be deleted.
* Every time you start the container, you will need to run
`rd-admin init` again and reinitialize the tracker.
* Every time you start the container, the tracker is initialized
and the 3 users are created.
* Once the container is running, you can start and stop the tracker
with `rd-start` and `ctrl+c`.
* When you register a new user, look in `python-dev/debugmail.txt`:
Expand Down
33 changes: 33 additions & 0 deletions image/bin/createusers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Create 3 users in the db:
* user: a regular user
* developer: a developer (triager) that signed the cla
* coordinator: a coordinator and committer that signed the cla

Most of the fields are the same as the username.
The password for all the users is 'pass'.
"""

import subprocess

rdadmin = ['/home/tracker/bin/roundup-admin', '-i', '/opt/tracker/python-dev']

users = ['user', 'developer', 'coordinator']
roles = []

for user in users:
# listing the role is not enough -- all lower-level roles
# must be added too (e.g. Coordinator,Developer,User)
roles.append(user.capitalize())
r = ','.join(roles)
ic = 1 if user == 'coordinator' else 0 # only coord is committer
args = ('create user username={u} address={u}@bugs.python.org '
'password=pass realname={u} github={u} roles={r} '

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't fill in github, it's not required, and might confuse. If one will be needing it, he can always set it.

'iscommitter={ic}'.format(u=user, r=r, ic=ic))
# developer and coordinator signed the cla
if user in {'developer', 'coordinator'}:
args += ' contrib_form=1 contrib_form_date=2017-03-22.00:00:00'

print('Creating user:', user)
print(' - user id:', end=' ', flush=True)
subprocess.run(rdadmin + args.split())
7 changes: 7 additions & 0 deletions image/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ function stop_all() {

trap stop_all HUP INT QUIT KILL TERM


# initialize the db (pwd: admin) and create users
sleep 5 # wait for PG to start...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the best solution, but the other solutions I found (e.g. http://stackoverflow.com/questions/35069027/docker-wait-for-postgresql-to-be-running ) seem a bit overkill.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still add a check if this is actually up after 5sec. so I'd go with this proposed solution:

while ! curl http://$POSTGRES_PORT_5432_TCP_ADDR:$POSTGRES_PORT_5432_TCP_PORT/ 2>&1 | grep '52'
do
  sleep 1
done

it's not big overkill and will give you confidence it's up at this point.

/home/tracker/bin/roundup-admin -i /opt/tracker/python-dev init admin
python3 /home/tracker/bin/createusers.py


if [ $# -eq 0 ]; then
/bin/bash
else
Expand Down