summaryrefslogtreecommitdiffstats
path: root/doc/markdown/dev_guide.md
blob: 1966d2e467254a0f2656ab9fb40d5aa094e0dd0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#Developer Guide

##Development Environment Setup

The workflow for libgfapi-python is largely based upon the [Gluster-Swift Developer Guide][]  and [OpenStack Gerrit Workflow][]. Refer to those documents for setting up a Gerrit account and a complete development environment.

This document focuses on setting up a quick environment for running tox tests (especially the functional tests).

## Required Package Installation
Install and start the required packages on your system to create a GlusterFS volume.
```
yum install gcc python-devel python-setuptools libffi-devel glusterfs \
    glusterfs-server git rpm-build xfsprogs
```

Install the python pip tool by executing the following command:

```
easy_install pip
```

#### Tox and Nose

libgfapi-python uses tox python virtual environment for its unit and functional tests. To install tox type:

```
pip install --upgrade tox nose
```

### Start services

Type the following to start the glusterfs service:

```
service glusterd start
```

Type the following to start the service automatically on system startup:

```
chkconfig glusterd on
```

## Gluster Volume Setup

### Loopback Storage Setup

If you do not have a separate partition, please execute the following instructions to create a disk image as a file:

```
truncate -s 5GB /srv/xfsdisk
mkfs.xfs -i size=512 /srv/xfsdisk
mkdir -p /export/brick
```

Add the following line to `/etc/fstab` to mount the storage automatically on system startup:

```
/srv/xfsdisk /export/brick   xfs   loop,inode64,noatime,nodiratime 0 0
```

Now type the following to mount the storage:

```
mount -a
```

## Create a GlusterFS Volume

You now need to create a GlusterFS volume

```
mkdir /export/brick/b1
gluster volume create test <hostname>:/export/brick/b1
gluster volume start test
```

## Download the Source

The source for libgfapi-python is available in Github. To download type:

```
git clone https://github.com/gluster/libgfapi-python.git
cd libgfapi-python
```

## Running tests

### PEP8

To test that the code adheres to the Python PEP8 specification, please type:

```
tox -e pep8
```

### Unit Tests

Once you have made your changes, you can test the quality of the code by executing the automated unit tests as follows:
```
tox -e ENV
```

where ENV is either py27 for systems with Python 2.7+, or py26 for systems with Python 2.6+.

If new functionality has been added, it is highly recommended that one or more tests be added to the automated unit test suite. Unit tests are available under the test/unit directory.

### Functional tests
The functional tests expects a `test` volume to be created and accessible.

To run the functional tests, please type:

```
tox -e functest
```
####Important Notes:
##### Definining a hostname
GlusterFS does not allow for specifiyng `localhost` as a valid hostname when creating a volume, so `gfshost` was used in the functional tests. If you use a different hostname when creating the gluster volume, be sure to update the functional tests.

##### Stopping services
For the purpose of running this test, stop the `firewalld` service and disable `selinux`.

```
service firewalld stop
```


[OpenStack Gerrit Workflow]: https://wiki.openstack.org/wiki/Gerrit_Workflow
[Gerrit]: https://code.google.com/p/gerrit/
[Gluster-Swift Developer Guide]: https://github.com/gluster/gluster-swift/blob/master/doc/markdown/dev_guide.md