From a42eadca6ad3af81eb7fcb68605d28f70364275c Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 8 Nov 2023 12:44:21 -0800 Subject: [PATCH] Improve etherpad functional testing This adds a testinfra test that creates a pad and retrieves its contents. Additionally adding 4 byte utf 8 characters to the stream to ensure the database is configured properly. Change-Id: Ie6855e201631ecf4fde6cda0c65941f094ed55d4 --- testinfra/test_etherpad.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/testinfra/test_etherpad.py b/testinfra/test_etherpad.py index 5f63d85f38..6c28dddef6 100644 --- a/testinfra/test_etherpad.py +++ b/testinfra/test_etherpad.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import urllib.parse testinfra_hosts = ['etherpad99.opendev.org'] @@ -34,3 +35,26 @@ def test_etherpad_logs(host): mariadb_log_file = host.file('/var/log/containers/docker-mariadb.log') assert mariadb_log_file.exists assert mariadb_log_file.contains('mysqld: ready for connections') + +def test_etherpad_4_byte_utf8(host): + # The 🖖 utf8 character is a four byte character. This test ensures we + # can set that value in a pad and get it back out again. This test both + # general functionality as well as proper database setup for four byte + # utf8 chars + teststr = '🖖 Live long and prosper 🖖' + urlstr = urllib.parse.quote(teststr) + cmd = host.run('sudo docker-compose -f ' + '/etc/etherpad-docker/docker-compose.yaml ' + 'exec -T etherpad cat /opt/etherpad-lite/APIKEY.txt') + token = cmd.stdout.strip() + cmd = host.run('wget -qO- "http://localhost:9001/api/1/createPad?' + 'apikey=%s&padID=testing"' % token) + assert '"code":0' in cmd.stdout + assert '"message":"ok"' in cmd.stdout + cmd = host.run('wget -qO- "http://localhost:9001/api/1/setText?' + 'apikey=%s&padID=testing&text=%s"' % (token, urlstr)) + assert '"code":0' in cmd.stdout + assert '"message":"ok"' in cmd.stdout + cmd = host.run('wget -qO- "http://localhost:9001/api/1/getText?' + 'apikey=%s&padID=testing"' % token) + assert teststr in cmd.stdout