@@ -38,6 +38,7 @@ F: package/flutter-gallery/
F: package/flutter-pi/
F: package/flutter-sdk-bin/
F: support/testing/tests/package/test_flutter.py
+F: support/testing/tests/package/test_postgresql.py
N: Adam Heinrich <adam@adamh.cz>
F: package/jack1/
new file mode 100644
@@ -0,0 +1,76 @@
+import os
+import time
+import infra.basetest
+
+
+class TestPostgreSQLInitd(infra.basetest.BRTest):
+ config: str = """
+ BR2_arm=y
+ BR2_cortex_a9=y
+ BR2_ARM_ENABLE_VFP=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+ BR2_PER_PACKAGE_DIRECTORIES=y
+ 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",
+ kernel_cmdline=["root=/dev/mmcblk0"],
+ options=["-drive", f"file={img},if=sd,format=raw"])
+ 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;'\"")
+
+
+class TestPostgreSQLSystemd(infra.basetest.BRTest):
+ config: str = """
+ 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_PER_PACKAGE_DIRECTORIES=y
+ 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",
+ kernel_cmdline=["root=/dev/mmcblk0"],
+ options=["-drive", f"file={img},if=sd,format=raw"])
+ self.emulator.login()
+
+ # Check if the Daemon is running
+ self.assertRunOk("ls /var/lib/pgsql/postmaster.pid")
+
+ # 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 active.")
+ # Check if we can connect to the database.
+ self.assertRunOk("cd / && su postgres -c \"psql -c 'SHOW server_version;'\"")
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. 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. Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com> --- DEVELOPERS | 1 + .../testing/tests/package/test_postgresql.py | 76 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 support/testing/tests/package/test_postgresql.py