From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Adam Duskett <adam.duskett@amarulasolutions.com>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH v2 2/2] support/testing/tests/package/test_postgresql.py: new test
Date: Mon, 18 Dec 2023 18:31:08 +0100 [thread overview]
Message-ID: <ZYCB3EqymtRdzOzd@landeda> (raw)
In-Reply-To: <20231102184154.46185-2-adam.duskett@amarulasolutions.com>
Adam, All,
On 2023-11-02 12:41 -0600, Adam Duskett spake thusly:
> Perform a basic check that performs the following:
> - Check if /var/lib/pgsql/postmaster.pid exists.
> - Check if 'psql -c SHOW server_version;' returns sucessfully.
Thanks for this new runtime test!
> Note: systemd takes quite a while to start up, so check the output of
> `systemctl is-active postgresql` until it shows "active" with a timeout
> of 15 seconds.
I think that we already concluded that testing if a unit was active or
not was not representing whether the service was actually running. In
the fultter test case for example, the unit was active, but the flutter
app was just keeping crashing again and again, so the test wsa failing
to detect failure...
So, I don't think usingt is-active is a good way to test whether a
service is actually running.
Furthermore, the unit may be active, but the service might not yet be
ready to serve, so again I don;t think it is still valid to reply on it.
> Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
> ---
> - Drop BR2_PER_PACKAGE_DIRECTORIES (Thomas)
Actually, I disagree with Thomas here: we added support for PPD in the
infra, so that if PPD is enabled in a test, then TLPB is done to speed
up the test.
[--SNIP--]
> diff --git a/support/testing/tests/package/test_postgresql.py b/support/testing/tests/package/test_postgresql.py
> new file mode 100644
> index 0000000000..fa692bab7b
> --- /dev/null
> +++ b/support/testing/tests/package/test_postgresql.py
> @@ -0,0 +1,73 @@
> +import os
> +import time
> +import infra.basetest
> +
> +
> +class TestPostgreSQLInitSysV(infra.basetest.BRTest):
> + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
> + """
> + BR2_PACKAGE_POSTGRESQL=y
> + BR2_TARGET_ROOTFS_EXT2=y
> + BR2_TARGET_ROOTFS_EXT2_4=y
> + BR2_TARGET_ROOTFS_EXT2_SIZE="128M"
> + # BR2_TARGET_ROOTFS_TAR is not set
> + """
> +
> + def test_run(self):
> + img = os.path.join(self.builddir, "images", "rootfs.ext2")
> + self.emulator.boot(
> + arch="armv5",
> + kernel="builtin",
> + options=["-drive", f"file={img},if=scsi,format=raw"],
> + kernel_cmdline=["root=/dev/sda"])
> + self.emulator.login()
> +
> + # Check if the Daemon is running
> + self.assertRunOk("ls /var/lib/pgsql/postmaster.pid")
> + # Check if we can connect to the database.
> + self.assertRunOk("su postgres -c \"psql -c 'SHOW server_version;'\"")
I don't understand why we need to test for the PID file before we
connect to the daemon. If the daemon is not running, we won't be able to
connect to it, so the test will fail, so the PID file test is redundant,
no?
Regards,
Yann E. MORIN.
> +
> +class TestPostgreSQLInitSystemd(infra.basetest.BRTest):
> + # Taken from test_systemd.py
> + config = """
> + BR2_arm=y
> + BR2_cortex_a9=y
> + BR2_ARM_ENABLE_VFP=y
> + BR2_TOOLCHAIN_EXTERNAL=y
> + BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
> + BR2_INIT_SYSTEMD=y
> + BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
> + BR2_PACKAGE_POSTGRESQL=y
> + BR2_TARGET_ROOTFS_EXT2=y
> + BR2_TARGET_ROOTFS_EXT2_4=y
> + BR2_TARGET_ROOTFS_EXT2_SIZE="128M"
> + # BR2_TARGET_ROOTFS_TAR is not set
> + """
> +
> + def test_run(self):
> + img = os.path.join(self.builddir, "images", "rootfs.ext2")
> + self.emulator.boot(
> + arch="armv7",
> + kernel="builtin",
> + options=["-drive", f"file={img},if=sd,format=raw"],
> + kernel_cmdline=["root=/dev/mmcblk0"])
> + self.emulator.login()
> +
> + # It may take some time for PostgreSQL to finish startup. Give it at least 15 seconds.
> + is_active = False
> + for i in range(15):
> + output, _ = self.emulator.run("systemctl is-active postgresql")
> + if output[0] == "active":
> + is_active = True
> + break
> + time.sleep(1)
> + if not is_active:
> + self.fail("postgresql failed to activate!")
> +
> + # Check if the Daemon is running
> + self.assertRunOk("ls /var/lib/pgsql/postmaster.pid")
> +
> + # Check if we can connect to the database.
> + self.assertRunOk("cd / && su postgres -c \"psql -c 'SHOW server_version;'\"")
> --
> 2.41.0
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2023-12-18 17:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-02 18:41 [Buildroot] [PATCH v2 1/2] package/postgresql/postgresql.service: set locale for initdb to C Adam Duskett
2023-11-02 18:41 ` [Buildroot] [PATCH v2 2/2] support/testing/tests/package/test_postgresql.py: new test Adam Duskett
2023-12-18 17:31 ` Yann E. MORIN [this message]
2023-12-18 17:41 ` Adam Duskett
2023-12-18 18:10 ` Adam Duskett
2023-12-18 20:44 ` Yann E. MORIN
2023-12-18 21:40 ` Adam Duskett
2023-11-05 10:07 ` [Buildroot] [PATCH v2 1/2] package/postgresql/postgresql.service: set locale for initdb to C Peter Seiderer
2023-12-18 17:22 ` Yann E. MORIN
2023-12-18 17:28 ` Adam Duskett
2023-12-18 17:39 ` Yann E. MORIN
2023-12-18 17:44 ` Adam Duskett
2023-12-18 22:09 ` Adam Duskett
2023-12-24 22:10 ` Adam Duskett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZYCB3EqymtRdzOzd@landeda \
--to=yann.morin.1998@free.fr \
--cc=adam.duskett@amarulasolutions.com \
--cc=buildroot@buildroot.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox