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

Add more OS platforms for wazuh-chef Kitchen tests #456

Merged
merged 30 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1e4ddd4
Re-structre kitchen/wazuh-chef test folders/files
rshad Feb 3, 2020
92a3b18
Adapt run.sh to 1-suite model
rshad Feb 3, 2020
a62335d
Adapt aux. loading attributes cookbook name
rshad Feb 4, 2020
1f831ce
Remove Gemfile; Not needed
rshad Feb 4, 2020
b53e437
Rename recipe
rshad Feb 4, 2020
9ab0a87
Parameterize Berksfile + specify it for each suite
rshad Feb 4, 2020
a223367
Remove clean.sh; Not needed
rshad Feb 4, 2020
72c966a
Remove development.json; Replaced by the template
rshad Feb 4, 2020
66bb96a
Parameterize run.sh
rshad Feb 4, 2020
3207122
Parameterize kitchen.yml; Parameterize cookbooks path
rshad Feb 4, 2020
1304462
Run /sbin/init to start sytemd
rshad Feb 4, 2020
db3eb1a
Improve tests for manager and agent
rshad Feb 4, 2020
a8ba797
Add provisioning command to install apt-transport-https gnupg2
rshad Feb 4, 2020
6a10369
Remove filebeat installation from basic test suite
rshad Feb 4, 2020
9ae8475
Remove provisioning commands from run.sh
rshad Feb 4, 2020
c3e42c2
Add provision. cmds to kitchen.yml + auto run cmds dep. on OS
rshad Feb 4, 2020
a703978
Auto remove docker images created by Kitchen
rshad Feb 5, 2020
900a613
Change tests folder name from tests to test
rshad Feb 5, 2020
e5ba47a
Remove filebeat attributes from testing environment files
rshad Feb 5, 2020
8436fc0
Adapt Dockerfile to use our fork for kitchen-docker
rshad Feb 5, 2020
688788b
Add support to Ubuntu 14. Avoid running some tests in such case
rshad Feb 6, 2020
c7fad6c
Add support for Ubuntu 14.04
rshad Feb 6, 2020
0c7a414
Parameterize run_command and use 1 entry platform
rshad Feb 7, 2020
c75c191
Replace hostname attribute in case of AmazonLinux2
rshad Feb 7, 2020
df31315
Fix ktichen-docker repo link
rshad Feb 7, 2020
98dd94c
Disable cache for Docker
rshad Feb 10, 2020
34ae967
Add kitchen-docker gem with fixes
rshad Feb 10, 2020
4702b74
Add Gemfile
rshad Feb 10, 2020
d3e7c15
Adapt Dockerfile to the new Gemfile path
rshad Feb 10, 2020
0f0dc3c
Remove redundat command and clean APT list
rshad Feb 10, 2020
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
FROM ruby

CMD tail -f /dev/null

COPY entrypoint.sh /usr/local/bin/

RUN chmod 777 /usr/local/bin/entrypoint.sh \
&& ln -s /usr/local/bin/entrypoint.sh /

ENTRYPOINT ["entrypoint.sh"]

RUN apt-get update && apt install docker.io git curl wget -y
xr09 marked this conversation as resolved.
Show resolved Hide resolved

RUN apt-get update
xr09 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -27,6 +18,14 @@ RUN cd $HOME && \
cd $HOME/wazuh-qa/kitchen/wazuh-chef/manager/files/ && \
bundle install

RUN git clone https://github.com/rshad/kitchen-docker && \
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be in any personal repo, please move it to a Wazuh repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @manuasir !

Now we have the fixes for kitchen-docker in this same branch.

Kr,

Rshad

cd kitchen-docker && \
git checkout fix-docker-image-deletion && \
git pull origin fix-docker-image-deletion

RUN rm -rf /usr/local/bundle/gems/kitchen-docker-2.9.0/* && \
cp -rf kitchen-docker/* /usr/local/bundle/gems/kitchen-docker-2.9.0/

RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py

RUN pip install pytest && pip install testinfra && pip install paramiko
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name 'test'
name 'load_attributes'
maintainer 'Wazuh Inc.'
maintainer_email '[email protected]'
license 'Apache 2.0'
Expand Down
52 changes: 52 additions & 0 deletions kitchen/wazuh-chef/common/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

set -e

development_agent_path="$COOKBOOKS_PATH/wazuh_agent/test/environments/development.json"
development_manager_path="$COOKBOOKS_PATH/wazuh_manager/test/environments/development.json"
development_manager_path_master="$COOKBOOKS_PATH/wazuh_manager/test/environments/development-master.json"

template=".template"

cd $SUITE_PATH

echo "Kitchen is creating the new instances"
kitchen create

echo "Getting Wazuh managers IPs to the agents"
manager_ip="$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' `docker ps | awk '{print $NF}' | grep $PLATFORM | grep $RELEASE | grep manager`)"

cp "$development_agent_path$template" "$development_agent_path"

echo "Assigning Wazuh managers IPs to the corresponding agents."
sed -i 's/manager-master.wazuh-test.com/'${manager_ip}'/g' $development_agent_path

echo "setting the manager registration and report IPs"

cp "$development_manager_path$template" "$development_manager_path"
sed -i 's/MANAGER_IP/'${manager_ip}'/g' $development_manager_path
cat $development_manager_path

cp "$development_manager_path_master$template" "$development_manager_path_master"
sed -i 's/MANAGER_IP/'${manager_ip}'/g' $development_manager_path_master
cat $development_manager_path_master

if [[ $PLATFORM == *"amazon"* ]]; then

sed -i 's/node\['.*hostname.*'\]/"amazon_agent"/g' "$COOKBOOKS_PATH/wazuh_agent/attributes/authd.rb"
fi


echo "Kitchen is converging ..."
kitchen converge -l debug

echo "Getting default things back"
cp "$development_agent_path$template" "$development_agent_path"
cp "$development_manager_path$template" "$development_manager_path"
cp "$development_manager_path_master$template" "$development_manager_path_master"

echo "Kitchen is testing ..."
kitchen verify

echo "Kitchen is destroying"
kitchen destroy
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {

},
"override_attributes": {
"ossec": {
"registration_address": "manager-master.wazuh-test.com",
"address": ["manager-master.wazuh-test.com"]
},
"filebeat": {
"ossec_type": "ossec-alerts-development",
"logstash_servers": "elk.wazuh-test.com:5000"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
}
}
}
},
"filebeat": {
"ossec_type": "ossec-alerts-development",
"logstash_servers": "elk.wazuh-test.com:5000"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "development-master",
"description": "The development environment",
"json_class": "Chef::Environment",
"chef_type": "environment"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {

},
"override_attributes": {
"ossec": {
"registration_address": "MANAGER_IP",
"address": ["MANAGER_IP", "MANAGER_IP"]
},
"filebeat": {
"ossec_type": "ossec-alerts-development",
"logstash_servers": "elk.wazuh-test.com:5000"
}
}
}
21 changes: 0 additions & 21 deletions kitchen/wazuh-chef/manager/development.json

This file was deleted.

26 changes: 0 additions & 26 deletions kitchen/wazuh-chef/manager/files/1-build-model/Dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions kitchen/wazuh-chef/manager/files/Berksfile

This file was deleted.

19 changes: 0 additions & 19 deletions kitchen/wazuh-chef/manager/files/Gemfile

This file was deleted.

12 changes: 0 additions & 12 deletions kitchen/wazuh-chef/manager/files/clean.sh

This file was deleted.

51 changes: 0 additions & 51 deletions kitchen/wazuh-chef/manager/files/dockerfile

This file was deleted.

39 changes: 0 additions & 39 deletions kitchen/wazuh-chef/manager/files/entrypoint/entrypoint.sh

This file was deleted.

Loading