Jump to: navigation, search

Difference between revisions of "Puppet/Functional testing"

(Running local tests)
(retire page)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
'''These docs are outdated, but kept here for historical reasons and search access. To view the latest docs, please refer to http://docs.openstack.org/developer/puppet-openstack-guide/'''
 +
 +
<strike>
 
The best reference for getting started with beaker can be found [https://github.com/puppetlabs/beaker/wiki here].
 
The best reference for getting started with beaker can be found [https://github.com/puppetlabs/beaker/wiki here].
  
Line 5: Line 8:
 
It will prepare the system and run beaker tests on the system.
 
It will prepare the system and run beaker tests on the system.
 
It's suggested to use a virtual machine for development.
 
It's suggested to use a virtual machine for development.
 +
 +
<br />
 +
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
#!/bin/bash
+
#!/bin/bash
if [ -f /usr/bin/yum ]; then
+
if [ -f /usr/bin/yum ]; then
    sudo yum -y install libxml2-devel libxslt-devel ruby-devel
+
    sudo yum -y install libxml2-devel libxslt-devel ruby-devel
    sudo yum -y groupinstall "Development Tools"
+
    sudo yum -y groupinstall "Development Tools"
    OS_TYPE='centos7'
+
    OS_TYPE='centos7'
elif [ -f /usr/bin/apt-get ]; then
+
elif [ -f /usr/bin/apt-get ]; then
    sudo apt-get update
+
    sudo apt-get update
    sudo apt-get install -y libxml2-dev libxslt-dev zlib1g-dev git ruby ruby-dev build-essential
+
    sudo apt-get install -y libxml2-dev libxslt-dev zlib1g-dev git ruby ruby-dev build-essential
    OS_TYPE='trusty'
+
    OS_TYPE='trusty'
fi
+
fi
echo "" | sudo tee -a /etc/ssh/sshd_config
+
echo "" | sudo tee -a /etc/ssh/sshd_config
echo "Match address 127.0.0.1" | sudo tee -a /etc/ssh/sshd_config
+
echo "Match address 127.0.0.1" | sudo tee -a /etc/ssh/sshd_config
echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
+
echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
echo "" | sudo tee -a /etc/ssh/sshd_config
+
echo "" | sudo tee -a /etc/ssh/sshd_config
echo "Match address ::1" | sudo tee -a /etc/ssh/sshd_config
+
echo "Match address ::1" | sudo tee -a /etc/ssh/sshd_config
echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
+
echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
mkdir -p .ssh
+
mkdir -p .ssh
ssh-keygen -f ~/.ssh/id_rsa -b 2048 -C "beaker key" -P ""
+
ssh-keygen -f ~/.ssh/id_rsa -b 2048 -C "beaker key" -P ""
sudo mkdir -p /root/.ssh
+
sudo mkdir -p /root/.ssh
sudo rm /root/.ssh/authorized_keys
+
sudo rm /root/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
+
cat ~/.ssh/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
if [ -f /usr/bin/yum ]; then
+
if [ -f /usr/bin/yum ]; then
    sudo systemctl restart sshd
+
    sudo systemctl restart sshd
elif [ -f /usr/bin/apt-get ]; then
+
elif [ -f /usr/bin/apt-get ]; then
    sudo service ssh restart
+
    sudo service ssh restart
fi
+
fi
sudo gem install bundler --no-rdoc --no-ri --verbose
+
sudo gem install bundler --no-rdoc --no-ri --verbose
mkdir .bundled_gems
+
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
+
export GEM_HOME=`pwd`/.bundled_gems
bundle install
+
bundle install
export BEAKER_set=nodepool-$OS_TYPE
+
export BEAKER_set=nodepool-$OS_TYPE
export BEAKER_debug=yes
+
export BEAKER_debug=yes
bundle exec rspec spec/acceptance
+
bundle exec rspec spec/acceptance
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
<br />
 +
  
 
The last command runs beaker tests by installing & testing the OpenStack service.
 
The last command runs beaker tests by installing & testing the OpenStack service.
 +
</strike>

Latest revision as of 23:29, 18 May 2016

These docs are outdated, but kept here for historical reasons and search access. To view the latest docs, please refer to http://docs.openstack.org/developer/puppet-openstack-guide/

The best reference for getting started with beaker can be found here.

Running local tests

The following script can invoked from any if the modules' directories to run their beaker tests. It assumes that both bundler as well as rubygems (and ruby) are already installed on the system. It will prepare the system and run beaker tests on the system. It's suggested to use a virtual machine for development.



#!/bin/bash
if [ -f /usr/bin/yum ]; then
    sudo yum -y install libxml2-devel libxslt-devel ruby-devel
    sudo yum -y groupinstall "Development Tools"
    OS_TYPE='centos7'
elif [ -f /usr/bin/apt-get ]; then
    sudo apt-get update
    sudo apt-get install -y libxml2-dev libxslt-dev zlib1g-dev git ruby ruby-dev build-essential
    OS_TYPE='trusty'
fi
echo "" | sudo tee -a /etc/ssh/sshd_config
echo "Match address 127.0.0.1" | sudo tee -a /etc/ssh/sshd_config
echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
echo "" | sudo tee -a /etc/ssh/sshd_config
echo "Match address ::1" | sudo tee -a /etc/ssh/sshd_config
echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
mkdir -p .ssh
ssh-keygen -f ~/.ssh/id_rsa -b 2048 -C "beaker key" -P ""
sudo mkdir -p /root/.ssh
sudo rm /root/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
if [ -f /usr/bin/yum ]; then
    sudo systemctl restart sshd
elif [ -f /usr/bin/apt-get ]; then
    sudo service ssh restart
fi
sudo gem install bundler --no-rdoc --no-ri --verbose
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
bundle install
export BEAKER_set=nodepool-$OS_TYPE
export BEAKER_debug=yes
bundle exec rspec spec/acceptance



The last command runs beaker tests by installing & testing the OpenStack service.