summaryrefslogtreecommitdiffstats
path: root/tests/basic/rpm.t
blob: ef4b5abf0cb8fc8dcb89602b34258e23aacf312a (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
#!/bin/bash

. $(dirname $0)/../include.rc

RESULT_DIR=$(mktemp -d -p /var/tmp rpm-tests.XXXXXXXX)

# enable some extra debugging
if [ -n "${DEBUG}" -a "${DEBUG}" != "0" ]
then
	exec &> ${RESULT_DIR}/log
	set -x
fi

# detect the branch we're based off
if [ -n "${BRANCH}" ] ; then
        # $BRANCH is set in the environment (by Jenkins or other)
        GIT_PARENT="origin/${BRANCH}"
else
        # get a reference to the latest clean tree
        GIT_PARENT=$(git describe --abbrev=0)
fi

# check for changed files
CHANGED_FILES=$(git diff --name-only ${GIT_PARENT})
# filter out any files not affecting the build itself
CHANGED_FILES=$(grep -E -v \
        -e '\.c$' \
        -e '\.h$' \
        -e '\.py$' \
        -e '^tests/' \
        <<< "${CHANGED_FILES}")
if [ -z "${CHANGED_FILES}" ]
then
        # only contents of files were changed, no need to retest rpmbuild
        SKIP_TESTS
	rm -rf ${RESULT_DIR}
        cleanup
        exit 0
fi

# checkout the sources to a new directory to execute ./configure and all
REPO=${PWD}
COMMIT=$(git describe)
mkdir ${RESULT_DIR}/sources
cd ${RESULT_DIR}/sources
git clone -q -s file://${REPO} .
git checkout -q -b rpm-test ${COMMIT}

# build the glusterfs-*.tar.gz
[ -e configure ] || ./autogen.sh 2>&1 > /dev/null
TEST ./configure --enable-fusermount
TEST make dist

# build the glusterfs src.rpm
ls extras
TEST make -C extras/LinuxRPM testsrpm

chmod g=rwx ${RESULT_DIR}
chown :mock ${RESULT_DIR}

# build for the last two Fedora EPEL releases (x86_64 only)
# TAP/Prove aren't smart about loops
TESTS_EXPECTED_IN_LOOP=2
for MOCK_CONF in $(ls -x1 /etc/mock/*.cfg | egrep -e 'epel-[0-9]+-x86_64.cfg$' | tail -n2)
do
	EPEL_RELEASE=$(basename ${MOCK_CONF} .cfg)
	mkdir ${RESULT_DIR}/${EPEL_RELEASE}
	chmod g=rwx ${RESULT_DIR}/${EPEL_RELEASE}
	chown :mock ${RESULT_DIR}/${EPEL_RELEASE}
	# expand the mock command line
	MOCK_CMD=$(echo /usr/bin/mock --cleanup-after \
		--resultdir=${RESULT_DIR}/${EPEL_RELEASE} \
		-r ${EPEL_RELEASE} --rebuild ${PWD}/*.src.rpm)

	# write the mock command to a file, so that its easier to execute
	cat << EOF > ${RESULT_DIR}/${EPEL_RELEASE}/mock.sh
#!/bin/sh
${MOCK_CMD}
EOF
	chmod +x ${RESULT_DIR}/${EPEL_RELEASE}/mock.sh

	# root can not run 'mock', it needs to drop priviledges
	if (groups | grep -q mock)
	then
		# the current user is in group 'mock'
		RUNMOCK="${RESULT_DIR}/${EPEL_RELEASE}/mock.sh"
	else
		# switch to the user called 'mock'
		chown mock:mock ${RESULT_DIR}/${EPEL_RELEASE}
		# "su" might not work, using sudo instead
		RUNMOCK="sudo -u mock -E ${RESULT_DIR}/${EPEL_RELEASE}/mock.sh"
	fi
        TEST_IN_LOOP ${RUNMOCK}
done

# we could build for the last two Fedora releases too, but that is not
# possible on EPEL-5/6 installations, Fedora 17 and newer have unmet
# dependencies on the build-server :-/

# only remove ${RESULT_DIR} if we're not debugging
[ "${DEBUG}" = "0" ] && rm -rf ${RESULT_DIR}

cleanup
LUSTERD_STORE_KEY_VOL_SUB_COUNT "sub_count" #define GLUSTERD_STORE_KEY_VOL_STRIPE_CNT "stripe_count" #define GLUSTERD_STORE_KEY_VOL_REPLICA_CNT "replica_count" #define GLUSTERD_STORE_KEY_VOL_BRICK "brick" #define GLUSTERD_STORE_KEY_VOL_VERSION "version" #define GLUSTERD_STORE_KEY_VOL_TRANSPORT "transport-type" #define GLUSTERD_STORE_KEY_VOL_ID "volume-id" #define GLUSTERD_STORE_KEY_RB_STATUS "rb_status" #define GLUSTERD_STORE_KEY_RB_SRC_BRICK "rb_src" #define GLUSTERD_STORE_KEY_RB_DST_BRICK "rb_dst" #define GLUSTERD_STORE_KEY_RB_DST_PORT "rb_port" #define GLUSTERD_STORE_KEY_VOL_DEFRAG "rebalance_status" #define GLUSTERD_STORE_KEY_DEFRAG_OP "rebalance_op" #define GLUSTERD_STORE_KEY_USERNAME "username" #define GLUSTERD_STORE_KEY_PASSWORD "password" #define GLUSTERD_STORE_KEY_BRICK_HOSTNAME "hostname" #define GLUSTERD_STORE_KEY_BRICK_PATH "path" #define GLUSTERD_STORE_KEY_BRICK_PORT "listen-port" #define GLUSTERD_STORE_KEY_BRICK_RDMA_PORT "rdma.listen-port" #define GLUSTERD_STORE_KEY_BRICK_DECOMMISSIONED "decommissioned" #define GLUSTERD_STORE_KEY_PEER_UUID "uuid" #define GLUSTERD_STORE_KEY_PEER_HOSTNAME "hostname" #define GLUSTERD_STORE_KEY_PEER_STATE "state" #define GLUSTERD_STORE_KEY_VOL_BACKEND "backend" #define glusterd_for_each_entry(entry, dir) \ do {\ entry = NULL;\ if (dir) {\ entry = readdir (dir);\ while (entry && (!strcmp (entry->d_name, ".") ||\ !strcmp (entry->d_name, ".."))) {\ entry = readdir (dir);\ }\ }\ } while (0); \ typedef enum { GD_STORE_SUCCESS, GD_STORE_KEY_NULL, GD_STORE_VALUE_NULL, GD_STORE_KEY_VALUE_NULL, GD_STORE_EOF, GD_STORE_ENOMEM, GD_STORE_STAT_FAILED } glusterd_store_op_errno_t; int32_t glusterd_store_volinfo (glusterd_volinfo_t *volinfo, glusterd_volinfo_ver_ac_t ac); int32_t glusterd_store_delete_volume (glusterd_volinfo_t *volinfo); int32_t glusterd_store_handle_new (char *path, glusterd_store_handle_t **handle); int32_t glusterd_store_save_value (int fd, char *key, char *value); int32_t glusterd_store_retrieve_value (glusterd_store_handle_t *handle, char *key, char **value); int32_t glusterd_retrieve_uuid (); int32_t glusterd_store_peerinfo (glusterd_peerinfo_t *peerinfo); int32_t glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo); int32_t glusterd_store_delete_brick (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo); int32_t glusterd_store_handle_destroy (glusterd_store_handle_t *handle); int32_t glusterd_restore (); void glusterd_perform_volinfo_version_action (glusterd_volinfo_t *volinfo, glusterd_volinfo_ver_ac_t ac); gf_boolean_t glusterd_store_is_valid_brickpath (char *volname, char *brick); int32_t glusterd_store_perform_node_state_store (glusterd_volinfo_t *volinfo); int glusterd_retrieve_op_version (xlator_t *this, int *op_version); int glusterd_store_global_info (xlator_t *this); int32_t glusterd_store_retrieve_options (xlator_t *this); int32_t glusterd_store_options (xlator_t *this, dict_t *opts); #endif