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
This commit is contained in:
Clark Boylan 2023-11-08 12:44:21 -08:00
parent 5e138a4b7d
commit a42eadca6a

View File

@ -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