Skip to content

Commit 0413b7e

Browse files
committed
Merge pull request github#55 from github/openldap-vagrant-box
[CI] Add Vagrant box for running tests against OpenLDAP locally
2 parents cc594e4 + bea78ba commit 0413b7e

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

test/support/vm/openldap/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.vagrant

test/support/vm/openldap/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Local OpenLDAP Integration Testing
2+
3+
Set up a [Vagrant](http://www.vagrantup.com/) VM to run tests against OpenLDAP locally.
4+
5+
To run tests against OpenLDAP (instead of ApacheDS) locally:
6+
7+
``` bash
8+
# start VM (from the correct directory)
9+
$ cd test/support/vm/openldap/
10+
$ vagrant up
11+
12+
# get the IP address of the VM
13+
$ ip=$(vagrant ssh -- "ifconfig eth1 | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n1")
14+
15+
# change back to root project directory
16+
$ cd ../../../..
17+
18+
# run all tests against OpenLDAP
19+
$ time TESTENV=openldap OPENLDAP_HOST=$ip bundle exec rake
20+
21+
# run a specific test file against OpenLDAP
22+
$ time TESTENV=openldap OPENLDAP_HOST=$ip bundle exec ruby test/membership_validators/recursive_test.rb
23+
24+
# run OpenLDAP tests by default
25+
$ export TESTENV=openldap
26+
$ export TESTENV=$ip
27+
28+
# now run tests without having to set ENV variables
29+
$ time bundle exec rake
30+
```
31+
32+
You may need to `gem install vagrant` first in order to provision the VM.

test/support/vm/openldap/Vagrantfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5+
VAGRANTFILE_API_VERSION = "2"
6+
7+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8+
config.vm.hostname = "openldap.github.org"
9+
10+
config.vm.box = "hashicorp/precise64"
11+
12+
config.vm.network "private_network", type: :dhcp
13+
14+
config.ssh.forward_agent = true
15+
16+
config.vm.provision "shell", inline: "apt-get update; exec env /vagrant_data/script/install-openldap"
17+
18+
config.vm.synced_folder "../../../..", "/vagrant_data"
19+
20+
config.vm.provider "vmware_fusion" do |vb, override|
21+
override.vm.box = "hashicorp/precise64"
22+
vb.memory = 4596
23+
vb.vmx["displayname"] = "integration tests vm"
24+
vb.vmx["numvcpus"] = "2"
25+
end
26+
27+
config.vm.provider "virtualbox" do |vb, override|
28+
vb.memory = 4096
29+
vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
30+
vb.customize ["modifyvm", :id, "--chipset", "ich9"]
31+
vb.customize ["modifyvm", :id, "--vram", "16"]
32+
end
33+
end

test/test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def options
7171
instrumentation_service: @service
7272
when "openldap"
7373
{
74-
host: 'localhost',
74+
host: ENV.fetch("OPENLDAP_HOST", "localhost"),
7575
port: 389,
7676
admin_user: 'uid=admin,dc=github,dc=com',
7777
admin_password: 'passworD1',

0 commit comments

Comments
 (0)