From Fedora Project Wiki
Description
Test deployment and basic functionality of a PostgreSQL server. All commands in this test case should be run as root.
Setup
- Perform a typical installation of the Fedora release you wish to run this test on. Boot the system, and log in as root.
How to test
- Install the necessary packages:
dnf -y install postgresql-server postgresql-contrib
- Configure the firewall:
firewall-cmd --permanent --add-service postgresql
systemctl restart firewalld.service
- Initialize the database:
/usr/bin/postgresql-setup --initdb
- Enable and start the systemd service:
systemctl enable postgresql.service
systemctl start postgresql.service
- Create the database owner:
su postgres -c "/usr/bin/createuser test"
- Create the database:
su postgres -c "/usr/bin/createdb test -O test"
- Set a password for the owner:
echo "ALTER ROLE test WITH PASSWORD 'correcthorse'" > /tmp/cmd
su postgres -c "psql test -f /tmp/cmd"
- Adjust postgresql.conf to allow network connections:
sed -i -e "s,.*listen_addresses *=.*,listen_addresses='*',g" /var/lib/pgsql/data/postgresql.conf
- Adjust pg_hba.conf to use md5 authentication:
sed -i -e "s,^host,#host,g" /var/lib/pgsql/data/pg_hba.conf
echo "host all all all md5" >> /var/lib/pgsql/data/pg_hba.conf
- Restart the systemd service:
systemctl restart postgresql.service
- check we can connect to the database and create a table:
su postgres -c "psql test -c 'CREATE TABLE test (testcol int);'"
- check we can add a row to the table:
su postgres -c "psql test -c 'INSERT INTO test VALUES (5);'"
- check we can query the table:
su postgres -c "psql test -c 'SELECT * FROM test;'"
- check we can modify the row:
su postgres -c "psql test -c 'UPDATE test SET testcol = 50 WHERE testcol = 5;'"
su postgres -c "psql test -c 'SELECT * FROM test;'"
Expected Results
- All commands should run without error
- The first SELECT command should show a single row with the value of testcol as 5
- The second SELECT command should show a single row with the value of testcol as 50.