URL: https://github.com/freeipa/freeipa/pull/4930
Author: rcritten
 Title: #4930: ipatests: Add healthcheck test for FileSystemSpaceCheck
Action: opened

PR body:
"""
Create a large file in one of the checked filesystems beyond
the allowed threshold and ensure that both the minimum space
and minimum percent errors are reported.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/4930/head:pr4930
git checkout pr4930
From 75a90833bf8125eee957dddb0fc0eaa7e938be19 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <[email protected]>
Date: Mon, 27 Apr 2020 16:50:16 -0400
Subject: [PATCH 1/6] WIP pwd history change

---
 daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c b/daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c
index b24a5ffab0..178633eb12 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/prepost.c
@@ -947,12 +947,14 @@ static int ipapwd_pre_mod(Slapi_PBlock *pb)
 
     /* put back a, possibly modified, set of mods */
     if (smods) {
-        mods = slapi_mods_get_ldapmods_passout(smods);
-        if (slapi_pblock_set(pb, SLAPI_MODIFY_MODS, mods)) {
-            LOG_FATAL("slapi_pblock_set failed!\n");
-            rc = LDAP_OPERATIONS_ERROR;
+        if (rc == 0) {
+            mods = slapi_mods_get_ldapmods_passout(smods);
+            if (slapi_pblock_set(pb, SLAPI_MODIFY_MODS, mods)) {
+                LOG_FATAL("slapi_pblock_set failed!\n");
+                rc = LDAP_OPERATIONS_ERROR;
+            }
+            slapi_mods_free(&smods);
         }
-        slapi_mods_free(&smods);
     }
 
     if (rc != LDAP_SUCCESS) {

From 26fa85d450345298dfbb822e5ec41961d5a5ec0e Mon Sep 17 00:00:00 2001
From: Peter Keresztes Schmidt <[email protected]>
Date: Fri, 5 Jun 2020 12:35:45 +0200
Subject: [PATCH 2/6] configure: Fix source tree detection to enable more
 warnings

Related: https://pagure.io/freeipa/issue/8351
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 9af77e2bce..2f2c4c2587 100644
--- a/configure.ac
+++ b/configure.ac
@@ -446,7 +446,7 @@ AC_ARG_ENABLE(more-warnings,
 	[AC_HELP_STRING([--enable-more-warnings],
 	[Maximum compiler warnings])],
 	set_more_warnings="$enableval",[
-        	if test -d $srcdir/../.hg; then
+        	if test -d $srcdir/.git; then
         		set_more_warnings=yes
               	else
                   	set_more_warnings=no

From b29ded7b92f0578e05b0f473dcf7554f22a96485 Mon Sep 17 00:00:00 2001
From: Peter Keresztes Schmidt <[email protected]>
Date: Fri, 5 Jun 2020 12:38:10 +0200
Subject: [PATCH 3/6] build: Unify compiler warning flags used

Related: https://pagure.io/freeipa/issue/8351
---
 client/Makefile.am  | 8 --------
 configure.ac        | 3 ++-
 daemons/Makefile.am | 8 --------
 3 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/client/Makefile.am b/client/Makefile.am
index 0031c04a55..91fa71235d 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -4,14 +4,6 @@ AUTOMAKE_OPTIONS = 1.7 subdir-objects
 
 NULL =
 
-AM_CFLAGS = $(NULL)
-if HAVE_GCC
-    AM_CFLAGS += -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith \
-		-Wcast-align -Werror-implicit-function-declaration \
-		$(NULL)
-endif
-export AM_CFLAGS
-
 IPA_CONF_FILE=$(sysconfdir)/ipa/default.conf
 
 AM_CPPFLAGS =							\
diff --git a/configure.ac b/configure.ac
index 2f2c4c2587..c9b23f7641 100644
--- a/configure.ac
+++ b/configure.ac
@@ -457,9 +457,10 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
         AC_MSG_RESULT(yes)
         CFLAGS="\
         -Wall \
-        -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
+        -Wmissing-declarations -Wmissing-prototypes \
         -Wnested-externs -Wpointer-arith \
         -Wcast-align -Wsign-compare \
+        -Wshadow -Wstrict-prototypes \
         $CFLAGS"
 
         for option in -Wno-strict-aliasing -Wno-sign-compare; do
diff --git a/daemons/Makefile.am b/daemons/Makefile.am
index 296791785e..f8f3ed5b25 100644
--- a/daemons/Makefile.am
+++ b/daemons/Makefile.am
@@ -4,14 +4,6 @@ AUTOMAKE_OPTIONS = 1.7 subdir-objects
 
 NULL =
 
-AM_CFLAGS = $(NULL)
-if HAVE_GCC
-    AM_CFLAGS += -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith \
-		-Wcast-align -Werror-implicit-function-declaration \
-		$(NULL)
-endif
-export AM_CFLAGS
-
 nodist_noinst_HEADERS = ipa-version.h
 noinst_HEADERS = ipa-version.h.in
 

From de8decf665a7899a719c77dfd3b25c87d571556e Mon Sep 17 00:00:00 2001
From: Peter Keresztes Schmidt <[email protected]>
Date: Fri, 5 Jun 2020 13:03:18 +0200
Subject: [PATCH 4/6] configure: Do not set -Wno-strict-aliasing
 -Wno-sign-compare

Related: https://pagure.io/freeipa/issue/8351
---
 configure.ac | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index c9b23f7641..1769af8bd8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -462,22 +462,6 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
         -Wcast-align -Wsign-compare \
         -Wshadow -Wstrict-prototypes \
         $CFLAGS"
-
-        for option in -Wno-strict-aliasing -Wno-sign-compare; do
-                SAVE_CFLAGS="$CFLAGS"
-                CFLAGS="$CFLAGS $option"
-                AC_MSG_CHECKING([whether gcc understands $option])
-                AC_TRY_COMPILE([], [],
-                        has_option=yes,
-                        has_option=no,)
-                if test $has_option = no; then
-                        CFLAGS="$SAVE_CFLAGS"
-                fi
-                AC_MSG_RESULT($has_option)
-                unset has_option
-                unset SAVE_CFLAGS
-        done
-        unset option
 else
         AC_MSG_RESULT(no)
 fi

From aaebcb07c8f0c7864f882cc261f31eb2f0af914e Mon Sep 17 00:00:00 2001
From: Rob Crittenden <[email protected]>
Date: Fri, 17 Jul 2020 10:45:02 -0400
Subject: [PATCH 5/6] ipatests: Add healthcheck test for FileSystemSpaceCheck

Create a large file in one of the checked filesystems beyond
the allowed threshold and ensure that both the minimum space
and minimum percent errors are reported.

Signed-off-by: Rob Crittenden <[email protected]>
---
 .../test_integration/test_ipahealthcheck.py   | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/ipatests/test_integration/test_ipahealthcheck.py b/ipatests/test_integration/test_ipahealthcheck.py
index ac13dbdfb3..e652cb8d5a 100644
--- a/ipatests/test_integration/test_ipahealthcheck.py
+++ b/ipatests/test_integration/test_ipahealthcheck.py
@@ -8,7 +8,9 @@
 from __future__ import absolute_import
 
 import json
+import os
 import re
+import uuid
 
 import pytest
 
@@ -904,3 +906,58 @@ def test_ipahealthcheck_trust_agent_member_check(self):
         for check in data:
             assert check["result"] == "SUCCESS"
             assert check["kw"]["key"] == self.master.hostname
+
+
+class TestIpaHealthCheckFilesystemSpace(IntegrationTest):
+    """
+    ipa-healthcheck tool test for running low on disk space.
+    """
+    num_replicas = 1
+
+    @classmethod
+    def install(cls, mh):
+        tasks.install_master(cls.master, setup_dns=True)
+        tasks.install_packages(cls.master, HEALTHCHECK_PKG)
+
+    @pytest.fixture
+    def create_jumbo_file(self):
+        """Calculate the free space and create a humongous file to fill it
+        within the threshold without using all available space."""
+
+        path = os.path.join('/tmp', str(uuid.uuid4()))
+        result = self.master.run_command(['df', '--output=avail', '/tmp'])
+        free = int(result.stdout_text.split('\n')[1]) * 1024
+        free = (free // 2**20) - 10
+        self.master.run_command(['fallocate', '-l', '%dMB' % free, path])
+
+        yield
+
+        self.master.run_command(['rm', path])
+
+    def test_ipa_filesystemspace_check(self, create_jumbo_file):
+        """
+        Create a large file in /tmp and verify that it reports low space
+
+        This should raise 2 errors. One that the available space is
+        below a size threshold and another that it is below a
+        percentage threshold.
+        """
+
+        returncode, data = run_healthcheck(
+            self.master,
+            "ipahealthcheck.system.filesystemspace",
+            "FileSystemSpaceCheck",
+            failures_only=True,
+        )
+        assert returncode == 1
+        for check in data:
+            assert check["result"] == "ERROR"
+            assert check["kw"]["store"] == "/tmp"
+            if check["kw"].get("percent_free"):
+                assert "/tmp: free space percentage under threshold" in \
+                    check["kw"]["msg"]
+                assert check["kw"]["threshold"] == 20
+            else:
+                assert "/tmp: free space under threshold" in \
+                    check["kw"]["msg"]
+                assert check["kw"]["threshold"] == 512

From 66af6706ad83771e131dd1e7c77fe864898d4523 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <[email protected]>
Date: Fri, 17 Jul 2020 14:19:37 -0400
Subject: [PATCH 6/6] Temp commit

---
 .freeipa-pr-ci.yaml                        | 2 +-
 ipatests/prci_definitions/temp_commit.yaml | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.freeipa-pr-ci.yaml b/.freeipa-pr-ci.yaml
index abcf8c5b63..8065669008 120000
--- a/.freeipa-pr-ci.yaml
+++ b/.freeipa-pr-ci.yaml
@@ -1 +1 @@
-ipatests/prci_definitions/gating.yaml
\ No newline at end of file
+ipatests/prci_definitions/temp_commit.yaml
\ No newline at end of file
diff --git a/ipatests/prci_definitions/temp_commit.yaml b/ipatests/prci_definitions/temp_commit.yaml
index e337068145..e65994e8d3 100644
--- a/ipatests/prci_definitions/temp_commit.yaml
+++ b/ipatests/prci_definitions/temp_commit.yaml
@@ -68,7 +68,7 @@ jobs:
       class: RunPytest
       args:
         build_url: '{fedora-latest/build_url}'
-        test_suite: test_integration/test_REPLACEME.py
+        test_suite: test_integration/test_ipahealthcheck.py::TestIpaHealthCheckFilesystemSpace
         template: *ci-master-latest
         timeout: 3600
-        topology: *master_1repl_1client
+        topology: *master_1repl
_______________________________________________
FreeIPA-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/[email protected]

Reply via email to