Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Integration tests README #4742

Merged
merged 8 commits into from
Jan 4, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## [4.8.1] - TBD

### Changed

- Updated integration tests README ([#4742](https://github.com/wazuh/wazuh-qa/pull/4742)) \- (Framework)

## [4.8.0] - TBD

### Added
Expand Down
141 changes: 82 additions & 59 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ tests modify the system date and there could be some synchronization issues.

This guide will cover the following platforms: [Linux](#linux), [Windows](#windows) and [MacOS](#macos).

You can run these tests on a manager or an agent. In case you are using an agent, please remember to register it and use
the correct version (Wazuh branch).
You can run these tests on a manager or an agent. In case you are using an agent, please remember to register it and use the correct version (Wazuh branch).

_We are skipping Wazuh installation steps. For further information,
check [Wazuh documentation](https://documentation.wazuh.com/3.11/installation-guide/index.html)._
check [Wazuh documentation](https://documentation.wazuh.com/current/installation-guide/index.html)._

### Linux

_We are using **CentOS** for this example:_

- Install **Wazuh**
- Install and start **Wazuh**

> [!NOTE]
> In case you are using an agent, please remember to register to the manager

- Disable firewall (only for **CentOS**)

Expand All @@ -32,101 +34,116 @@ systemctl stop firewalld
systemctl disable firewalld
```

- Install Python and its dependencies
- Install Python3

```shell script
# Install dependencies
yum install make gcc policycoreutils-python automake autoconf libtool epel-release git which sudo wget -y

# Install development dependencies for jq library
yum groupinstall "Development Tools" -y

# Install Python3
yum install python36 python36-pip python36-devel -y

# Install Python libraries
pip3 install pytest freezegun jq jsonschema pyyaml==5.3 psutil distro pandas==0.25.3 pytest-html==2.0.1 numpydoc==0.9.2
```

- Add some internal options and restart
Copy link
Member

Choose a reason for hiding this comment

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

Apart from installing dependencies,
Shouldn't the setting of internal options be retained?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 15215b3


- Avoid agent disconnections when travelling in time (only for agents)
```shell script
# Enable debug 2
echo 'syscheck.debug=2' >> $wazuh_path/etc/local_internal_options.conf

# Avoid agent disconnections when travelling in time (only for agents)
sed -i "s:<time-reconnect>60</time-reconnect>:<time-reconnect>99999999999</time-reconnect>:g" /var/ossec/etc/ossec.conf

# Disable log rotation
```

- Disable log rotation
```shell script
echo 'monitord.rotate_log=0' >> $wazuh_path/etc/local_internal_options.conf
```

# Restart Wazuh
- Restart Wazuh
```shell script
/var/ossec/bin/wazuh-control restart
```

- Install integration tests dependencies

```shell script
cd wazuh-qa
python -m pip install -r requirements.txt
```

- Install wazuh-testing framework

```shell script
cd deps/wazuh_testing/
python setup.py install
```

> [!NOTE]
> When developing tests, utilize the following command to seamlessly update the framework with each modification.
```shell script
python -m pip install . -e
```


### Windows

- Install **Wazuh**
- Install and start **Wazuh**

> [!NOTE]
> In case you are using an agent, please remember to register to the manager

- Download and install [Python](https://www.python.org/downloads/windows/)

- Download and install [chocolatey](https://chocolatey.org/docs/installation) to be able to install `jq` using the
terminal.

- Install `jq`:
- Change `time-reconnect` from `C:\Program Files (x86)\ossec-agent\ossec.conf`
```xml
<time-reconnect>99999999999</time-reconnect>
```

- Add some internal options
```shell script
choco install jq
# Disable log rotation
echo 'monitord.rotate_log=0' >> "C:\Program Files (x86)\ossec-agent\local_internal_options.conf"
```

- Install Python dependencies
- Restart **Wazuh** using the GUI

- Install `jq`:

```shell script
pip install pytest freezegun jsonschema pyyaml==5.4 psutil paramiko distro pywin32 pypiwin32 wmi pandas==0.25.3 pytest-html==2.0.1 numpydoc==0.9.2
choco install jq
```

- Change `time-reconnect` from `C:\Program Files (x86)\ossec-agent\ossec.conf`
Copy link
Member

Choose a reason for hiding this comment

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

More internal options to take into consideration.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 15215b3

- Install integration tests dependencies

```xml
<time-reconnect>99999999999</time-reconnect>
```shell script
cd wazuh-qa
python -m pip install -r requirements.txt
```

- Add some internal options
- Install wazuh-testing framework

```shell script
# Enable debug 2
echo 'syscheck.debug=2' >> "C:\Program Files (x86)\ossec-agent\local_internal_options.conf"

# Disable log rotation
echo 'monitord.rotate_log=0' >> "C:\Program Files (x86)\ossec-agent\local_internal_options.conf"
cd deps/wazuh_testing/
python setup.py install
```

- Restart **Wazuh** using the GUI
> [!NOTE]
> When developing tests, utilize the following command to seamlessly update the framework with each modification.
```
python -m pip install . -e
```

### MacOS

- Install **Wazuh**
- Install and start **Wazuh**

- Install Python and its dependencies
> [!NOTE]
> Remember to register the agent to the manager

```shell script
# Install Python
brew install python3

# Install dependencies
brew install autoconf automake libtool

# Install Python libraries
pip3 install filetype freezegun jq jsonschema lockfile numpydoc psutil pytest-html pytest-testinfra pyyaml
```shell script
brew install python3
```

- Add some internal options and restart
Copy link
Member

Choose a reason for hiding this comment

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

More internal options to take into consideration.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 15215b3


```shell script

# Enable debug 2
echo 'syscheck.debug=2' >> /Library/Ossec/etc/local_internal_options.conf

# Avoid agent disconnections when travelling in time
brew install gnu-sed
gsed -i "s:<time-reconnect>60</time-reconnect>:<time-reconnect>99999999999</time-reconnect>:g" /Library/Ossec/etc/ossec.conf
Expand All @@ -138,9 +155,19 @@ echo 'monitord.rotate_log=0' >> /Library/Ossec/etc/local_internal_options.conf
/Library/Ossec/bin/wazuh-control restart
```

-----------
- Install Python and its dependencies

Finally, copy your `wazuh-qa` repository within your testing environment and you are set.
```shell script
cd wazuh-qa
python -m pip install -r requirements.txt
```

- Install wazuh-testing framework

```shell script
cd deps/wazuh_testing/
python setup.py install
```

## Integration tests

Expand Down Expand Up @@ -278,14 +305,11 @@ This will be our python module with all the needed code to test everything.

### Dependencies

To run them, we need to install all these Python dependencies:

It is necessary to install the wazuh testing framework dependencies:
```shell script
pip3 install distro freezegun jq jsonschema psutil pytest pyyaml==5.3 pandas==0.25.3 pytest-html==2.0.1 numpydoc==0.9.2
python -m pip install -r requirements.txt
```

_**NOTE:** `jq` library can only be installed with `pip` on **Linux**_

### Wazuh-Testing package

We have a Python package at `wazuh-qa/deps/` with all the tools needed to run these tests. From file monitoring classes
Expand Down Expand Up @@ -354,7 +378,6 @@ To install it:

```shell script
cd wazuh-qa/deps/wazuh_testing
pip3 install .
```

_**NOTE:** It is important to reinstall this package every time we modify anything
Expand Down
Loading