Merge pull request #5 from noahdesu/wip-travis-ci-build

test: fix travis-ci builds

Signed-off-by: Noah Watkins noahwatkins@gmail.com
This commit is contained in:
Noah Watkins 2014-11-27 16:42:24 -08:00
commit 860a0316a9
4 changed files with 123 additions and 20 deletions

View File

@ -8,17 +8,12 @@ before_install:
- ssh-keygen -f $HOME/.ssh/id_rsa -t rsa -N '' - ssh-keygen -f $HOME/.ssh/id_rsa -t rsa -N ''
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
- chmod 600 ~/.ssh/authorized_keys - chmod 600 ~/.ssh/authorized_keys
- sudo apt-get -y install python-virtualenv - sudo pip install ceph-deploy
- git clone https://github.com/ceph/ceph-deploy - ceph-deploy install --release giant `hostname`
- cd ceph-deploy - ceph-deploy pkg --install librados-dev `hostname`
- ./bootstrap - bash ci/micro-osd.sh /tmp/micro-ceph
- ./ceph-deploy install --release firefly `hostname` - export CEPH_CONF=/tmp/micro-ceph/ceph.conf
- ./ceph-deploy pkg --install librados-dev `hostname` - ceph status
install:
- echo "asdf"
script: "exit 0"
notifications: notifications:
recipients: recipients:

View File

@ -1,5 +1,7 @@
# go-rados - Go bindings for RADOS distributed object store # go-rados - Go bindings for RADOS distributed object store
[![Build Status](https://travis-ci.org/noahdesu/go-rados.svg)](https://travis-ci.org/noahdesu/go-rados)
## Installation ## Installation
go get github.com/noahdesu/go-rados go get github.com/noahdesu/go-rados

90
ci/micro-osd.sh Normal file
View File

@ -0,0 +1,90 @@
#
# Copyright (C) 2013,2014 Loic Dachary <loic@dachary.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
set -e
set -u
DIR=$1
#if ! dpkg -l ceph ; then
# wget -q -O- 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc' | sudo apt-key add -
# echo deb http://ceph.com/debian-dumpling/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
# sudo apt-get update
# sudo apt-get --yes install ceph ceph-common
#fi
# get rid of process and directories leftovers
pkill ceph-mon || true
pkill ceph-osd || true
rm -fr $DIR
# cluster wide parameters
mkdir -p ${DIR}/log
cat >> $DIR/ceph.conf <<EOF
[global]
fsid = $(uuidgen)
osd crush chooseleaf type = 0
run dir = ${DIR}/run
auth cluster required = none
auth service required = none
auth client required = none
osd pool default size = 1
EOF
export CEPH_ARGS="--conf ${DIR}/ceph.conf"
# single monitor
MON_DATA=${DIR}/mon
mkdir -p $MON_DATA
cat >> $DIR/ceph.conf <<EOF
[mon.0]
log file = ${DIR}/log/mon.log
chdir = ""
mon cluster log file = ${DIR}/log/mon-cluster.log
mon data = ${MON_DATA}
mon addr = 127.0.0.1
EOF
ceph-mon --id 0 --mkfs --keyring /dev/null
touch ${MON_DATA}/keyring
ceph-mon --id 0
# single osd
OSD_DATA=${DIR}/osd
mkdir ${OSD_DATA}
cat >> $DIR/ceph.conf <<EOF
[osd.0]
log file = ${DIR}/log/osd.log
chdir = ""
osd data = ${OSD_DATA}
osd journal = ${OSD_DATA}.journal
osd journal size = 100
osd objectstore = memstore
EOF
OSD_ID=$(ceph osd create)
ceph osd crush add osd.${OSD_ID} 1 root=default host=localhost
ceph-osd --id ${OSD_ID} --mkjournal --mkfs
ceph-osd --id ${OSD_ID}
# check that it works
rados --pool rbd put group /etc/group
rados --pool rbd get group ${DIR}/group
diff /etc/group ${DIR}/group
ceph osd tree
export CEPH_CONF="${DIR}/ceph.conf"

View File

@ -2,7 +2,7 @@ package rados_test
import "testing" import "testing"
//import "bytes" //import "bytes"
import "github.com/noahdesu/rados" import "github.com/noahdesu/go-rados"
import "github.com/stretchr/testify/assert" import "github.com/stretchr/testify/assert"
import "os" import "os"
import "os/exec" import "os/exec"
@ -85,28 +85,37 @@ func TestGetClusterStats(t *testing.T) {
pool, err := conn.OpenPool(poolname) pool, err := conn.OpenPool(poolname)
assert.NoError(t, err) assert.NoError(t, err)
buf := make([]byte, 1<<22) // grab current stats
pool.Write("obj", buf, 0) prev_stat, err := conn.GetClusterStats()
fmt.Printf("prev_stat: %+v\n", prev_stat)
assert.NoError(t, err)
// make some changes to the cluster
buf := make([]byte, 1<<20)
for i := 0; i < 10; i++ {
objname := GetUUID()
pool.Write(objname, buf, 0)
}
// wait a while for the stats to change
for i := 0; i < 30; i++ { for i := 0; i < 30; i++ {
stat, err := conn.GetClusterStats() stat, err := conn.GetClusterStats()
assert.NoError(t, err) assert.NoError(t, err)
// wait a second if stats are zero // wait for something to change
if stat.Kb == 0 || stat.Kb_used == 0 || if stat == prev_stat {
stat.Kb_avail == 0 || stat.Num_objects == 0 { fmt.Printf("curr_stat: %+v (trying again...)\n", stat)
fmt.Println("waiting for cluster stats to refresh")
time.Sleep(time.Second) time.Sleep(time.Second)
} else { } else {
// success // success
fmt.Printf("curr_stat: %+v (change detected)\n", stat)
conn.Shutdown() conn.Shutdown()
return return
} }
} }
t.Error("Cluster stats are zero")
conn.Shutdown() conn.Shutdown()
t.Error("Cluster stats aren't changing")
} }
func TestGetFSID(t *testing.T) { func TestGetFSID(t *testing.T) {
@ -207,6 +216,13 @@ func TestPingMonitor(t *testing.T) {
return return
} }
// mon id that should work with micro-osd.sh
reply, err = conn.PingMonitor("0")
if err == nil {
assert.NotEqual(t, reply, "")
return
}
// try to use a hostname as the monitor id // try to use a hostname as the monitor id
mon_addr, _ := conn.GetConfigOption("mon_host") mon_addr, _ := conn.GetConfigOption("mon_host")
hosts, _ := net.LookupAddr(mon_addr) hosts, _ := net.LookupAddr(mon_addr)