<commit_before># JVM Puppet Acceptance Testing

This directory is intended to manage acceptance testing for the JVM Puppet
Master.

## Acceptance Testing for Dummies

This setup is intended for developers when running a VM on their local machine.
This will not use Vagrant or a Rakefile, but instead a local VM and the beaker CLI.

#### Prepare the VM

1. Get a fresh EL6 VM installed in VMWare or VirtualBox
   - One can be downloaded at: http://int-resources.ops.puppetlabs.net/pe-supported-virtual-machines/centos6-64.vmwarevm.tar.bz2
2. Install your SSH key on the VM so beaker can connect without authentication
3. Set the system clock to prevent issues such as SSL authentication
   - You'll need ntp or ntpdate and then run: ```ntpdate time.apple.com```
4. Take a snapshot of the VM now that you have a pristine OS with SSH access
   - You'll want to revert back to this snapshot every time the run fails during pre_suite

#### Define a hosts config file for your new VM

1. Copy/modify the local EL6 host config at ./config/beaker/local/el6/1host.cfg to have the hostname and IP of your VM
   - Change the line at the top that looks like ```centos6-64-1.local:``` to the hostname of your VM
   - Change the ```ip``` value to your VM

#### Define the JVMPUPPET_REPO_CONFIG environment variable

The one thing you'll need before running the tests via beaker is a URL to the repository file that contains the most recent package of jvm-puppet.

1. Go to http://builds.puppetlabs.lan/jvm-puppet
2. Scroll down to the bottom and go into the most recent one
   - This will look like: 0.1.4.SNAPSHOT.2014.05.15T1118/
3. Drill down into repo_configs/rpm and then the appropriate one for your VM (and 64 or 32 bit)
   - Assuming that you have a 32-bit EL6 this will look like: pl-jvm-puppet-0.1.4.SNAPSHOT.2014.05.15T1118-el-6-i386.repo
4. Copy the URL for this file (and make sure it's "http" and not "https" otherwise you'll get curl errors during the run)

#### Run Beaker

    export JVMPUPPET_REPO_CONFIG=<URL FROM PREVIOUS STEP>
    bundle install --path vendor/bundle
    bundle exec beaker --config <PATH TO YOUR HOSTS CONFIG FILE> --type foss --debug --fail-mode slow --helper ./acceptance/lib/helper.rb --pre-suite ./acceptance/suites/pre_suite --tests ./acceptance/suites/tests

This should kick off a beaker run against your new VM that will run all the pre_suite steps and then the simple "no op" testtest.rb that we have in jvm-puppet/acceptance.

If the run fails during a pre-suite step, you'll need to revert your VM back to the previous state, resolve the error, and try again.
Otherwise, the next run will fail as the pre-suite steps assume a fresh machine and are not tolerant of existing installations.

If the run succeeds, you'll want to take another snapshot of VM so you can disable the pre-suite setup in subsequent runs for faster iteration.

#### Iterative Development & Debugging

Now that you've done a successful beaker run and taken a VM snapshot, it's time to run beaker again using the actual acceptance tests in the puppet repository.
It's important that you run the tests from the same version of Puppet that has been installed on your VM.

You can find the version that is installed by running ```puppet --version```.
Make sure that your cloned puppet repository on your machine is at the same version as above.
This probably just means a simple ```git checkout tags/<version>```.

Now you will want to run beaker again, but this time without the pre-suite argument and using the puppet acceptance tests.

    bundle exec beaker --config <PATH TO YOUR HOSTS CONFIG FILE> --type foss --debug --fail-mode slow --helper ./acceptance/lib/helper.rb --tests <PATH TO THE PUPPET REPO ON YOUR MACHINE>/acceptance/tests

You should now be in a good state for running & debugging the acceptance tests.
When the tests fail, you may want to revert the VM back to the previous snapshot (the one you took right after a successful pre-suite setup) before you run them again.
This may be necessay because the tests can leave the machine in the same state it was in prior, and subsequent runs may be affected.

## Hypervisors

This acceptance testing suite has so far only been configured to work with
VirtualBox using Beaker/Vagrant. To add support for additional Vagrant boxes or
hypervisors, add Beaker config files to the './acceptance/config/beaker' directory.  
  
The default Beaker config is ./acceptance/config/beaker/vbox/el6/64/1host.cfg. This value
can be overridden with the BEAKER_CONFIG environment variable.
<commit_msg>Add clock note; highlight some important parts<commit_after># JVM Puppet Acceptance Testing

This directory is intended to manage acceptance testing for the JVM Puppet
Master.

## Acceptance Testing for Dummies

This setup is intended for developers when running a VM on their local machine.
This will not use Vagrant or a Rakefile, but instead a local VM and the beaker CLI.

#### Prepare the VM

1. Get a fresh EL6 VM installed in VMWare or VirtualBox
   - One can be downloaded at: http://int-resources.ops.puppetlabs.net/pe-supported-virtual-machines/centos6-64.vmwarevm.tar.bz2
2. Install your SSH key on the VM so beaker can connect without authentication
3. Set the system clock to prevent issues such as SSL authentication
   - You'll need ntp or ntpdate and then run: ```ntpdate time.apple.com```
4. Take a snapshot of the VM now that you have a pristine OS with SSH access
   - You'll want to revert back to this snapshot every time the run fails during pre_suite
   - Note that **you might need to set the clock again after each VM restore**

#### Define a hosts config file for your new VM

1. Copy/modify the local EL6 host config at ./config/beaker/local/el6/1host.cfg to have the hostname and IP of your VM
   - Change the line at the top that looks like ```centos6-64-1.local:``` to the hostname of your VM
   - Change the ```ip``` value to your VM

#### Define the JVMPUPPET_REPO_CONFIG environment variable

The one thing you'll need before running the tests via beaker is a URL to the repository file that contains the most recent package of jvm-puppet.

1. Go to http://builds.puppetlabs.lan/jvm-puppet
2. Scroll down to the bottom and go into the most recent one
   - This will look like: 0.1.4.SNAPSHOT.2014.05.15T1118/
3. Drill down into repo_configs/rpm and then the appropriate one for your VM (and 64 or 32 bit)
   - Assuming that you have a 32-bit EL6 this will look like: pl-jvm-puppet-0.1.4.SNAPSHOT.2014.05.15T1118-el-6-i386.repo
4. Copy the URL for this file (and _make sure it's "http" and not "https" otherwise you'll get curl SSL errors during pre-suite_)

#### Run Beaker

    export JVMPUPPET_REPO_CONFIG=<URL FROM PREVIOUS STEP>
    bundle install --path vendor/bundle
    bundle exec beaker --config <PATH TO YOUR HOSTS CONFIG FILE> --type foss --debug --fail-mode slow --helper ./acceptance/lib/helper.rb --pre-suite ./acceptance/suites/pre_suite --tests ./acceptance/suites/tests

This should kick off a beaker run against your new VM that will run all the pre_suite steps and then the simple "no op" testtest.rb that we have in jvm-puppet/acceptance.

If the run fails during a pre-suite step, you'll need to revert your VM back to the previous state, resolve the error, and try again.
Otherwise, the next run will fail as the pre-suite steps assume a fresh machine and are not tolerant of existing installations.

When the run succeeds, you'll want to **take another snapshot of VM** so you can disable the pre-suite setup in subsequent runs for faster iteration.

#### Iterative Development & Debugging

Now that you've done a successful beaker run and taken a VM snapshot, it's time to run beaker again using the actual acceptance tests in the puppet repository.
It's important that you run the tests from the same version of Puppet that has been installed on your VM.

You can find the version that is installed by running ```puppet --version```.
Make sure that your cloned puppet repository on your machine is at the same version as above.
This probably just means a simple ```git checkout tags/<version>```.

Now you will want to run beaker again, but this time without the pre-suite argument and using the puppet acceptance tests.

    bundle exec beaker --config <PATH TO YOUR HOSTS CONFIG FILE> --type foss --debug --fail-mode slow --helper ./acceptance/lib/helper.rb --tests <PATH TO THE PUPPET REPO ON YOUR MACHINE>/acceptance/tests

You should now be in a good state for running & debugging the acceptance tests.
When the tests fail, you may want to revert the VM back to the previous snapshot (the one you took right after a successful pre-suite setup) before you run them again.
This may be necessay because the tests can leave the machine in the same state it was in prior, and subsequent runs may be affected.

## Hypervisors

This acceptance testing suite has so far only been configured to work with
VirtualBox using Beaker/Vagrant. To add support for additional Vagrant boxes or
hypervisors, add Beaker config files to the './acceptance/config/beaker' directory.  
  
The default Beaker config is ./acceptance/config/beaker/vbox/el6/64/1host.cfg. This value
can be overridden with the BEAKER_CONFIG environment variable.

{'fraction_non_alphanumeric': 0.06268947596362061, 'fraction_numerical': 0.01429190125595496, 'mean_word_length': 3.853914871255912, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7618091', 'n_tokens_mistral': 2674, 'n_tokens_neox': 2539, 'n_words': 1392}