Skip to content

Commit

Permalink
Cleaning up some missed things
Browse files Browse the repository at this point in the history
This commit removes Vagrant-based tests. It also updates the README file
to remove references to the allinone class. It also adds information
about how to test the code without the Vagrant-based tests.
  • Loading branch information
avitacco committed Jan 31, 2025
1 parent 26cbb7b commit 8576d60
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 232 deletions.
96 changes: 95 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Contributing Guide

Please follow [the instructions on graylog.org](https://www.graylog.org/get-involved/).

#### Code of Conduct
## Code of Conduct

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
Expand All @@ -10,3 +12,95 @@ nationality, personal appearance, race, religion, or sexual identity and
orientation.

Please read and understand the [Code of Conduct](https://github.com/Graylog2/puppet-graylog/blob/master/CODE_OF_CONDUCT.md).

## Development

### testing
PDK supports three different types of tests, and contributions are expected to pass all three suites.

#### Validation
PDK should be used to validate the following items:
* metadata.json syntax
* Puppet syntax
* Puppet code style
* Ruby code style

To run the validation is simple.

```bash
pdk validate --parallel
```

#### Unit tests
All classes should have associated unit tests. If you are developing a new class or contributing code to an existing one, it is expected that the code will be accompanied by associated unit test(s).

To run the unit test suite is fairly easy
```bash
# Run the full suite in parallel
pdk test unit --parallel

# Run a specific test
pdk test unit --tests=./spec/classes/init_spec.rb
```

#### Acceptance testing
To ensure that this module actually does what is expected on a managed machine, we need to test the actual application of it. This is accomplished via litmus, which utilizes docker containers to run the module. The running of this suite is broken up into several different steps.

1. Provision the container(s)
2. Install the puppet agent on the container(s)
3. Install the graylog module (and dependencies) on the container(s)
4. Apply the module and test the container(s)
5. Clean up the container(s)

A normal development process would follow steps 1-4 and then repeat 3 and 4 until all tests pass and then step 5.

For more information about litmus, please see [the documentation](https://puppetlabs.github.io/litmus/).

##### Provision container(s)
There are several sets of containers defined for this module in `provision.yaml`. The full test suite is called default, but this is an arbitrary name. For development, it may be desirable to have only a single container to test against for that you could utilize the set named single.

```bash
# The full set of supported OS containers
pdk bundle exec rake 'litmus:provision_list[default]'

# A single Ubuntu 22.04 container (for quicker test runs)
pdk bundle exec rake 'litmus:provision_list[single]'

# Debian family containers
pdk bundle exec rake 'litmus:provision_list[debian]'

# RedHat family containers
pdk bundle exec rake 'litmus:provision_list[redhat]'
```

##### Install the puppet agent
In order to run puppet code on the containers, puppet needs to be installed on them. It is possible to specify which version of the agent to install, but the default is the latest version.

```bash
# Install latest
pdk bundle exec rake 'litmus:install_agent'

# Install puppet 7
pdk bundle exec rake 'litmus:install_agent[puppet7]'
```

##### Install the module (and dependencies)
Every time you change module code, you need to ensure that code is installed on the test containers.

```bash
pdk bundle exec rake 'litmus:install_module'
```

##### Run the acceptance tests
The acceptance tests run puppet code on the test containers and examines the containers after to ensure that the systems look the way the tests say they should. The thing to note about the acceptance tests is that they don't revert the state of the container between units.

```bash
pdk bundle exec rake 'litmus:acceptance:parallel'
```

##### Clean up the containers
Once you no longer need the containers or need to start again with clean containers, you can run the command to delete all of them.

```bash
pdk bundle exec rake 'litmus:tear_down'
```
74 changes: 14 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ class { '::graylog::server':

* `graylog::repository`: Manages the official Graylog package repository
* `graylog::server`: Installs, configures and manages the Graylog server service
* `graylog::allinone`: Creates a full Graylog setup including MongoDB and OpenSearch

#### Private Classes

Expand Down Expand Up @@ -282,55 +281,6 @@ Additional java options for Graylog. Defaults to ``.
This setting restarts the `graylog-server` service if the os package is upgraded.
It defaults to `false`.

#### Class: graylog::allinone

The `graylog::allinone` class configures a complete Graylog system including
MongoDB and OpenSearch

**Note:** This is nice to quickly setup a running system on a single node but
should only be used for testing or really small setups.
Use the `graylog::server` class for production deployments.

This class is using two Puppet modules from the forge to setup a complete system.
Please make sure you have these installed before using the `graylog::allinone` class.

Requirements:

* [puppet/mongodb](https://forge.puppet.com/puppet/mongodb)
* [puppet/opensearch](https://forge.puppet.com/modules/puppet/opensearch)

##### `opensearch`

This setting is used to configure the `opensearch` Puppet module.

There is only on possible hash key:

* `version`: The OpenSearch version to use

Example:

```
opensearch => {
version => '2.9.0',
}
```

##### `graylog`

This setting is used to configure the `graylog::repository` and `graylog::server`
classes.

Example:

```
graylog => {
major_version => '6.1',
config => {
# ... see graylog::server description for details
},
}
```

## Limitations

Supported Graylog versions:
Expand All @@ -343,17 +293,21 @@ Supported platforms:
* RedHat/CentOS

## Development

You can test this module by using [Vagrant](https://www.vagrantup.com/).
It uses the `graylog::allinone` class to setup a complete system inside
the Vagrant box.

You can test this module by using the associated PDK commands.

```bash
pdk validate # Ensure code style conforms to recommendations
pdk test unit --parallel # Run unit tests (in parallel)

#
# Acceptance (litmus) tests, requires docker
#
pdk bundle exec rake 'litmus:provision_list[default]'
pdk bundle exec rake 'litmus:install_agent'
pdk bundle exec rake 'litmus:install_module'
pdk bundle exec rake 'litmus:acceptance:parallel'
pdk bundle exec rake 'litmus:tear_down'
```
$ vagrant up rockylinux8
$ vagrant provision rockylinux8
```

This is a quick way to see how the module behaves on a real machine.

Please see the [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
files for further details.
Expand Down
76 changes: 0 additions & 76 deletions Vagrantfile

This file was deleted.

12 changes: 0 additions & 12 deletions tests/init.pp

This file was deleted.

40 changes: 0 additions & 40 deletions tests/install/files/sysconfig-puppetserver

This file was deleted.

16 changes: 0 additions & 16 deletions tests/install/manifests/puppetserver.pp

This file was deleted.

27 changes: 0 additions & 27 deletions tests/vagrant.pp

This file was deleted.

0 comments on commit 8576d60

Please sign in to comment.