Skip to content

Commit

Permalink
Fixed outdated things in puppet provisioning. Updated readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
martent committed Jan 27, 2021
1 parent 0bbceb0 commit c72d7df
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 55 deletions.
52 changes: 29 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ MEKS is a management system for unaccompanied children, their asylum status, log
## Dependencies

* nginx (for production)
* Ruby 2.6.x
* Ruby managed by rbenv
* MySQL >= 5.7
* ElasticSearch 6.x
* ElasticSearch
* Memcached
* [Global Assets](https://github.com/malmostad/global-assets).

Expand Down Expand Up @@ -34,15 +34,40 @@ Log in to the Vagrant box as the `vagrant` user and start the application in the
```shell
$ vagrant ssh
$ cd /vagrant
$ rails s -b 0.0.0.0
$ bundle exec puma
```

Point a browser on your host system to http://127.0.0.1:3035. Editing of the project files on your host system will be reflected when you hit reload in your browser.
You can use seed files to create dummy data and three users, *a* (administrator) *w* (writer) and *r* (reader). After that you can login with one of the tree roles (no password).

```shell
$ cd /vagrant
$ bundle exec rake db:seed
$ bundle exec rake db:seed_rate_categories
```

Point a browser on your host system to http://127.0.0.1:3036. Editing of the project files on your host system will be reflected when you hit reload in your browser.

When you run the `vagrant up` command for the first time it creates an Ubuntu 16.04 based Vagrant box with a ready-to-use development environment for the application. This will take some time. Vagrant will launch fast after the first run.

If you get port conflicts in your host system, change `forwarded_port` in the `Vagrantfile` You might also want to edit the value for `vm.hostname` and `puppet.facter` in the same file or do a mapping `localhost` mapping in your hosts `host` file to reflect that value.

## Testing
Run tests before pushing code to the Git repository and before making a deployment. The application contains unit tests and high level integration/feature tests using RSpec, Capybara and headless Chrome.

Note: Installation of Chrome, ChromeDriver and Selenium are currently not provided by the Puppet provisioning script for the Vagrant box. See `puppet/install_chrome_etc.txt` for installation commands.

Note that the environment used for RSpec currently is `local_test`. Add an entry for that environment in `config/secrets.yml`.

Run the test cases in the projects root directory in your Vagrant box:

```shell
$ bundle exec rspec
```
Currently, if some tests fail, you may want to execute a second test run. This is because an rspec order issue that hasn't been tracked down yet.

```shell
$ bundle exec rspec --only-failures
```

## Server Provisioning

Expand Down Expand Up @@ -96,24 +121,5 @@ $ bundle exec cap production deploy

The worker for delayed job that is used for gererating reports is managed by `systemd`. The process is killed after a deployment and `systemd` is starting it automaticaly.


## Testing
Run tests before pushing code to the Git repository and before making a deployment. The application contains unit tests and high level integration/feature tests using RSpec, Capybara and headless Chrome.

Note: Installation of Chrome, ChromeDriver and Selenium are currently not provided by the Puppet provisioning script for the Vagrant box. See `puppet/install_chrome_etc.txt` for installation commands.

Run the test cases in the projects root directory in your Vagrant box:

```shell
$ bundle exec rspec
```
Currently, if some tests fail, you may want to execute a second test run. This is because an rspec order issue that hasn't been tracked down yet.

```shell
$ bundle exec rspec --only-failures
```

Note that the environment used for RSpec is `local_test`.

## License
Released under AGPL version 3.
11 changes: 5 additions & 6 deletions puppet/install_chrome_etc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@ sudo apt-get -y install google-chrome-stable
google-chrome-stable --version

# Install ChromeDriver
## URL to latest version is found at https://chromedriver.chromium.org/
sudo apt-get install -y unzip xvfb libxi6 libgconf-2-4
sudo apt-get install default-jdk
wget https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip
wget https://chromedriver.storage.googleapis.com/88.0.4324.96/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/local/bin/chromedriver
sudo chown root:root /usr/local/bin/chromedriver
sudo chmod +x /usr/local/bin/chromedriver
# Test it
chromedriver --url-base=/wd/hub

# Uninstall ChromeDriver RubyGem, if present, which is slow
which chromedriver
# Uninstall the ChromeDriver RubyGem, if present
gem list | grep chrome
gem uninstall chromedriver-helper
rm /home/vagrant/.rbenv/shims/chromedriver
rbenv rehash

# Install Selenium
wget https://selenium-release.storage.googleapis.com/3.13/selenium-server-standalone-3.14.0.jar
sudo mv selenium-server-standalone-3.14.0.jar /usr/local/bin/selenium-server-standalone.jar
wget https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
sudo mv selenium-server-standalone-3.141.59.jar /usr/local/bin/selenium-server-standalone.jar
sudo chown root:root /usr/local/bin/selenium-server-standalone.jar
sudo chmod 0755 /usr/local/bin/selenium-server-standalone.jar
# Test it
Expand Down
4 changes: 2 additions & 2 deletions puppet/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

class { '::mcommons::elasticsearch':
version => '6.x',
version => '5.x',
memory => '1g',
}

Expand All @@ -26,7 +26,7 @@
class { '::mcommons::nginx': }

class { '::mcommons::ruby':
version => '2.5.3',
version => '2.6.3', # Use the version from .ruby-version
}

class { 'mcommons::ruby::unicorn': }
Expand Down
47 changes: 23 additions & 24 deletions puppet/vagrant.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,41 @@

class { '::mcommons': }

class { '::mcommons::mysql':
-> class { '::mcommons::mysql':
db_password => '',
db_root_password => '',
create_test_db => true,
daily_backup => false,
ruby_enable => true,
}

class { '::mcommons::elasticsearch':
version => '6.x',
-> class { '::mcommons::elasticsearch':
version => '5.x',
memory => '200m',
}

# -> exec {'Create ElasticSearch index':
# command => "bundle exec rake environment elasticsearch:reindex RAILS_ENV=development CLASS='Recommendation' ALIAS='recommendations' ; exit 0",
# user => $::runner_name,
# path => $::runner_path,
# cwd => $::app_home,
# }
#
# -> exec {'Create ElasticSearch index for test':
# command => "bundle exec rake environment elasticsearch:reindex RAILS_ENV=test CLASS='Recommendation' ALIAS='recommendations' ; exit 0",
# user => $::runner_name,
# path => $::runner_path,
# cwd => $::app_home,
# }

class { '::mcommons::memcached':
-> class { '::mcommons::memcached':
memory => 16,
}

class { '::mcommons::ruby':
version => '2.5.3',
-> class { '::mcommons::ruby':
version => '2.6.3', # Use the version from .ruby-version
}

class { 'mcommons::ruby::bundle_install': }
class { 'mcommons::ruby::rails': }
class { 'mcommons::ruby::rspec_deps': }
# mcommons::ruby::db_migrate { $::envs: }
-> exec { 'Update Gem System':
command => '/usr/bin/env gem update --system',
user => $::runner_name,
path => $::runner_path,
cwd => $::app_home,
}

-> class { 'mcommons::ruby::bundle_install': }
-> class { 'mcommons::ruby::rails': }
-> class { 'mcommons::ruby::rspec_deps': }

-> exec { "Load schema to database":
command => "bundle exec rake db:schema:load",
user => $::runner_name,
path => $::runner_path,
cwd => $::app_home,
}

0 comments on commit c72d7df

Please sign in to comment.