Bug 1067059

Summary: Support for unit tests in GlusterFS
Product: [Community] GlusterFS Reporter: Luis Pabón <lpabon>
Component: buildAssignee: Luis Pabón <lpabon>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: low Docs Contact:
Priority: unspecified    
Version: mainlineCC: bugs, gluster-bugs, lpabon, madam, ndevos, sasundar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glusterfs-3.6.0beta1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-11 08:28:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Luis Pabón 2014-02-19 15:15:33 UTC
Description of problem:
Add support in GlusterFS for C Unit Tests.  C unit test framework is based on cmockery2 (https://github.com/lpabon/cmockery2) which allows for mocking of C functions.  cmockery2 also allows for Jenkins integration by showing unit tests results and coverage information.

Work is being done in https://github.com/lpabon/glusterfs/tree/xunit.  Jenkins integration results can be seen here:

http://build.gluster.org/job/glusterfs-unittests/

I will be adding unit tests for mem-pool.c and also a document on how to create unit tests for GlusterFS.


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Luis Pabón 2014-02-19 15:16:37 UTC
Public Trello card for work:

https://trello.com/b/dTlPxmpV/glusterfs-unit-test-infrastructure-project

Comment 2 Anand Avati 2014-02-20 18:52:40 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#1) for review on master by Luis Pabon (lpabon)

Comment 3 Anand Avati 2014-02-24 10:33:22 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#2) for review on master by Vijay Bellur (vbellur)

Comment 4 Anand Avati 2014-02-24 10:48:25 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#3) for review on master by Vijay Bellur (vbellur)

Comment 5 Anand Avati 2014-02-24 11:10:58 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#4) for review on master by Vijay Bellur (vbellur)

Comment 6 Anand Avati 2014-02-25 18:46:26 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#5) for review on master by Luis Pabon (lpabon)

Comment 7 Anand Avati 2014-02-25 18:46:44 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#6) for review on master by Luis Pabon (lpabon)

Comment 8 Anand Avati 2014-02-26 10:31:50 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#7) for review on master by Luis Pabon (lpabon)

Comment 9 Anand Avati 2014-02-26 10:32:04 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#8) for review on master by Luis Pabon (lpabon)

Comment 10 Anand Avati 2014-02-27 04:45:32 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#9) for review on master by Luis Pabon (lpabon)

Comment 11 Anand Avati 2014-02-27 11:45:13 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#10) for review on master by Luis Pabon (lpabon)

Comment 12 Anand Avati 2014-02-27 18:02:18 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#11) for review on master by Luis Pabon (lpabon)

Comment 13 Anand Avati 2014-02-27 18:39:49 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#12) for review on master by Luis Pabon (lpabon)

Comment 14 Anand Avati 2014-02-27 19:29:59 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#13) for review on master by Luis Pabon (lpabon)

Comment 15 Anand Avati 2014-02-28 09:57:36 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#14) for review on master by Luis Pabon (lpabon)

Comment 16 Anand Avati 2014-03-02 09:10:55 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#15) for review on master by Luis Pabon (lpabon)

Comment 17 Anand Avati 2014-03-02 09:19:08 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#16) for review on master by Luis Pabon (lpabon)

Comment 18 Anand Avati 2014-03-03 19:54:57 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#17) for review on master by Luis Pabon (lpabon)

Comment 19 Anand Avati 2014-03-04 13:33:25 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#18) for review on master by Luis Pabon (lpabon)

Comment 20 Anand Avati 2014-03-04 13:37:00 UTC
REVIEW: http://review.gluster.org/7145 (build: GlusterFS Unit Test Framework) posted (#19) for review on master by Luis Pabon (lpabon)

Comment 21 Anand Avati 2014-03-06 12:11:00 UTC
COMMIT: http://review.gluster.org/7145 committed in master by Vijay Bellur (vbellur) 
------
commit c817c214033481fe59f9f44c325a9092dc337d07
Author: Luis Pabon <lpabon>
Date:   Thu Feb 20 13:50:19 2014 -0500

    build: GlusterFS Unit Test Framework
    
    This patch will allow for developers to create unit tests for
    their code.  Documentation has been added to the patch and
    is available here:
    
    doc/hacker-guide/en-US/markdown/unittest.md
    
    Also, unit tests are run when RPM is created.
    
    BUG: 1067059
    Change-Id: I95cf8bb0354d4ca4ed4476a0f2385436a17d2369
    Signed-off-by: Vijay Bellur <vbellur>
    Signed-off-by: Luis Pabon <lpabon>
    Reviewed-on: http://review.gluster.org/7145
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Rajesh Joseph <rjoseph>
    Reviewed-by: Justin Clift <justin>
    Tested-by: Justin Clift <justin>

Comment 22 Niels de Vos 2014-03-10 08:54:49 UTC
Nightly builds for glusterfs/master are failing for a while, and this change seems to be the cause :-/

Currently the glusterfs.tar.gz that gets generated with 'make dist' bundles the cmockery2 code. This should be a normal build-dependency, just like any other library.

Checking out a 2nd git repository while generating a 'make dist' tarball is very fragile. This can now not be an offline procedure anymore. It also assumes that the build-system has git available (new build dependency). It is currently not possible to update/patch some of Makefile.am or configure.ac and re-run ./autogen.sh when git is not available, or when github.com can not be reached.

Also most downstream distributions frown upon code bundling. For example, Fedora advises to 'rm -rf' any bundled libraries/files that are included in the 'make dist' tarballs before building code.


When looking for cmockery(2) packages in Fedora, I found libcmocka (http://cmocka.org/). This seems to be the replacement for cmockery, and upstream is more active. This makes me wonder if we should proceed with the cmockery2 dependency, or move to the more recent libcmocka?

Comment 23 Luis Pabón 2014-03-12 19:24:22 UTC
Where can I get information on how to create the nightly build on my development system so that I can investigate the issue.

On Cmocka:
I have no issues about cmocka, but I just wanted a very simple way for developers to create unit tests.  Cmocka is Cmake based and cannot be part of the tree.  Developers will have to install it (which is not a big deal, but my goal was to be as non-intrusive as possible).
My enhancements to cmockery to support PBC and Junit xml can be ported to cmocka if we ever want to go that way.

FYI, cmockery is pretty stable, must of the work in cmocka and cmockery2 is around the build system.

Comment 24 Anand Avati 2014-06-30 17:42:26 UTC
REVIEW: http://review.gluster.org/7538 (build: Support for unit tests using Cmockery2) posted (#19) for review on master by Luis Pabon (lpabon)

Comment 25 Anand Avati 2014-06-30 17:48:35 UTC
REVIEW: http://review.gluster.org/7538 (build: Support for unit tests using Cmockery2) posted (#20) for review on master by Luis Pabon (lpabon)

Comment 26 Anand Avati 2014-07-01 15:00:00 UTC
REVIEW: http://review.gluster.org/7538 (build: Support for unit tests using Cmockery2) posted (#21) for review on master by Luis Pabon (lpabon)

Comment 27 Anand Avati 2014-07-01 15:00:06 UTC
REVIEW: http://review.gluster.org/7538 (build: Support for unit tests using Cmockery2) posted (#22) for review on master by Luis Pabon (lpabon)

Comment 28 Anand Avati 2014-07-10 12:33:47 UTC
REVIEW: http://review.gluster.org/7538 (build: Support for unit tests using Cmockery2) posted (#23) for review on master by Luis Pabon (lpabon)

Comment 29 Anand Avati 2014-07-16 16:31:29 UTC
REVIEW: http://review.gluster.org/7538 (build: Support for unit tests using Cmockery2) posted (#24) for review on master by Luis Pabon (lpabon)

Comment 30 Anand Avati 2014-07-16 16:34:47 UTC
REVIEW: http://review.gluster.org/7538 (build: Support for unit tests using Cmockery2) posted (#25) for review on master by Luis Pabon (lpabon)

Comment 31 Anand Avati 2014-07-18 17:55:57 UTC
COMMIT: http://review.gluster.org/7538 committed in master by Vijay Bellur (vbellur) 
------
commit 13f644f78336c79850b332c35ad439fda8dac4fa
Author: Luis Pabon <lpabon>
Date:   Wed Apr 23 16:18:57 2014 -0400

    build: Support for unit tests using Cmockery2
    
    This patch will allow for developers to create unit tests for
    their code.  Documentation has been added to the patch and
    is available here:
    
    doc/hacker-guide/en-US/markdown/unittest.md
    
    Also, unit tests are run when RPM is created.
    
    This patch is a replacement for http://review.gluster.org/#/c/7281
    which removed unit test infrastucture from the repo due to multiple
    conflicts.  Cmockery2 is now available in Fedora and EPEL, and soon
    to be available in Debian and Ubuntu.  For all other operating
    systems, please install from the source:
    
    https://github.com/lpabon/cmockery2
    
    BUG: 1067059
    
    Change-Id: I1b36cb1f56fd10916f9bf535e8ad080a3358289f
    Signed-off-by: Luis Pabón <lpabon>
    Reviewed-on: http://review.gluster.org/7538
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Niels de Vos <ndevos>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 32 Niels de Vos 2014-09-22 12:36:21 UTC
A beta release for GlusterFS 3.6.0 has been released. Please verify if the release solves this bug report for you. In case the glusterfs-3.6.0beta1 release does not have a resolution for this issue, leave a comment in this bug and move the status to ASSIGNED. If this release fixes the problem for you, leave a note and change the status to VERIFIED.

Packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update (possibly an "updates-testing" repository) infrastructure for your distribution.

[1] http://supercolony.gluster.org/pipermail/gluster-users/2014-September/018836.html
[2] http://supercolony.gluster.org/pipermail/gluster-users/

Comment 33 Niels de Vos 2014-11-11 08:28:13 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.6.1, please reopen this bug report.

glusterfs-3.6.1 has been announced [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://supercolony.gluster.org/pipermail/gluster-users/2014-November/019410.html
[2] http://supercolony.gluster.org/mailman/listinfo/gluster-users

Comment 34 Anand Avati 2015-02-03 14:32:48 UTC
REVIEW: http://review.gluster.org/9568 (build: better support for cmockery2 unit tests) posted (#1) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 35 Anand Avati 2015-02-04 20:21:28 UTC
REVIEW: http://review.gluster.org/9568 (build: better support for cmockery2 unit tests) posted (#2) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 36 Anand Avati 2015-02-05 08:55:03 UTC
REVIEW: http://review.gluster.org/9568 (build: better support for cmockery2 unit tests) posted (#3) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 37 Anand Avati 2015-02-24 22:45:39 UTC
REVIEW: http://review.gluster.org/9738 (build: better support for cmockery2 unit tests) posted (#1) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 38 Anand Avati 2015-03-04 20:25:34 UTC
REVIEW: http://review.gluster.org/9738 (testing: Switch to cmocka the successor of cmockery2) posted (#2) for review on master by Niels de Vos (ndevos)

Comment 39 Anand Avati 2015-03-04 20:25:42 UTC
REVIEW: http://review.gluster.org/9801 (build: require cmocka >= 1.0.1) posted (#1) for review on master by Niels de Vos (ndevos)

Comment 40 Anand Avati 2015-03-04 20:25:50 UTC
REVIEW: http://review.gluster.org/9802 (build: require cmocka by default for unit testing) posted (#1) for review on master by Niels de Vos (ndevos)

Comment 41 Anand Avati 2015-03-04 22:17:35 UTC
REVIEW: http://review.gluster.org/9738 (testing: Switch to cmocka the successor of cmockery2) posted (#3) for review on master by Niels de Vos (ndevos)

Comment 42 Anand Avati 2015-03-04 22:21:08 UTC
REVIEW: http://review.gluster.org/9738 (testing: Switch to cmocka the successor of cmockery2) posted (#4) for review on master by Niels de Vos (ndevos)

Comment 43 Anand Avati 2015-03-04 22:21:44 UTC
REVIEW: http://review.gluster.org/9801 (build: require cmocka >= 1.0.1) posted (#2) for review on master by Niels de Vos (ndevos)

Comment 44 Anand Avati 2015-03-04 22:21:55 UTC
REVIEW: http://review.gluster.org/9802 (build: require cmocka by default for unit testing) posted (#2) for review on master by Niels de Vos (ndevos)

Comment 45 Anand Avati 2015-03-05 21:51:46 UTC
COMMIT: http://review.gluster.org/9738 committed in master by Kaleb KEITHLEY (kkeithle) 
------
commit bc2e58a436002e1627a225663bc7b11dddc1172f
Author: Niels de Vos <ndevos>
Date:   Wed Feb 18 14:47:01 2015 +0100

    testing: Switch to cmocka the successor of cmockery2
    
    This uses https://cmocka.org/ as the unit testing framework.
    
    With this change, unit testing is made optional as well. We assume there
    is no cmocka available while building. cmocka will be enabled by default
    later on. For now, to build with cmocka run:
    
        $ ./configure --enable-cmocka
    
    This change is based on the work of Andreas (replacing cmockery2 with
    cmocka) and Kaleb (make cmockery2 an optional build dependency).
    
    The only modifications I made, are additional #defines in unittest.h for
    making sure the unit tests function as expected.
    
    Change-Id: Iea4cbcdaf09996b49ffcf3680c76731459cb197e
    BUG: 1067059
    Merged-change: http://review.gluster.org/9762/
    Signed-off-by: Andreas Schneider <asn>
    Signed-off-by: Kaleb S. KEITHLEY <kkeithle>
    Signed-off-by: Niels de Vos <ndevos>
    Change-Id: Ia2e955481c102d5dce17695a9205395a6030e985
    Reviewed-on: http://review.gluster.org/9738
    Tested-by: Gluster Build System <jenkins.com>

Comment 46 Anand Avati 2015-03-31 11:11:22 UTC
COMMIT: http://review.gluster.org/9801 committed in master by Kaleb KEITHLEY (kkeithle) 
------
commit 9c37b68bc15c503a0ad5cc2fb04be7b917496d90
Author: Niels de Vos <ndevos>
Date:   Tue Mar 3 00:27:34 2015 +0100

    build: require cmocka >= 1.0.1
    
    Our mem-pool unit test does a funky realloc(ptr, 0) as an alternative to
    free(ptr). cmocka 1.0.0 has a bug where this is not handled correctly
    and thinks to detect a memory leak. The next cmocka release will have
    this bug fixed, making our unit tests require cmocka >= 1.0.1.
    
    URL: https://cmocka.org/archive/cmocka/2015-02/0000059.html
    Change-Id: I3d7f9b4cf7ace3f958158425ecbcc8f176579122
    BUG: 1067059
    Signed-off-by: Niels de Vos <ndevos>
    Reviewed-on: http://review.gluster.org/9801
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Andreas Schneider <asn>
    Tested-by: Andreas Schneider <asn>
    Reviewed-by: Kaleb KEITHLEY <kkeithle>

Comment 47 Anand Avati 2015-04-01 10:33:03 UTC
REVIEW: http://review.gluster.org/9802 (build: require cmocka by default for unit testing) posted (#3) for review on master by Niels de Vos (ndevos)