Skip to content

Commit

Permalink
Add binary recording test
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-stephenson committed Oct 9, 2020
1 parent ada0bac commit 0e8f87a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ blocks:
- bots/image-customize -v -i cockpit-ws -i `pwd`/cockpit-session-recording*.noarch.rpm -s `pwd`/test/vm.install $TEST_OS
- bots/image-customize -v -r "usermod -u 981 tlog || true" $TEST_OS
- bots/image-customize -v -u ./test/files/1.journal:/var/log/journal/1.journal $TEST_OS
- bots/image-customize -v -u ./test/files/binary-rec.journal:/var/log/journal/binary-rec.journal $TEST_OS
- test/check-application -v
- name: Check centos-8
commands:
- export TEST_OS=centos-8-stream
- bots/image-customize -v -i cockpit-ws -i `pwd`/cockpit-session-recording*.noarch.rpm -s `pwd`/test/vm.install $TEST_OS
- bots/image-customize -v -r "usermod -u 981 tlog || true" $TEST_OS
- bots/image-customize -v -u ./test/files/1.journal:/var/log/journal/1.journal $TEST_OS
- bots/image-customize -v -u ./test/files/binary-rec.journal:/var/log/journal/binary-rec.journal $TEST_OS
- test/check-application -v
epilogue:
on_fail:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ $(VM_IMAGE): $(RPMFILE) bots
bots/image-customize -v -i cockpit-ws -i `pwd`/$(RPMFILE) -s $(CURDIR)/test/vm.install $(TEST_OS)
bots/image-customize -v -r "usermod -u 981 tlog || true" $(TEST_OS)
bots/image-customize -v -u ./test/files/1.journal:/var/log/journal/1.journal $(TEST_OS)
bots/image-customize -v -u ./test/files/binary-rec.journal:/var/log/journal/binary-rec.journal $(TEST_OS)

# convenience target for the above
vm: $(VM_IMAGE)
Expand Down
66 changes: 45 additions & 21 deletions test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import os
import sys
import time
import json
import configparser

# import Cockpit's machinery for test VMs and its browser test API
TEST_DIR = os.path.dirname(__file__)
Expand All @@ -21,28 +24,55 @@ class TestApplication(MachineCase):
b.wait_present("#app")
return b, m

def _sel_rec(self, index=0):
page = (
"0f25700a28c44b599869745e5fda8b0c-7106-121e79"
if not index
else "0f25700a28c44b599869745e5fda8b0c-7623-135541"
)
def _sel_rec(self, recording):
'''
rec1:
whoami
id
echo thisisatest123
sleep 16
echo thisisanothertest456
exit
rec2:
echo "Extra Commands"
sudo systemctl daemon-reload
sudo ssh root@localhost
exit
binaryrec:
cat /usr/bin/gzip
'''
recordings = {'rec1': '0f25700a28c44b599869745e5fda8b0c-7106-121e79',
'rec2': '0f25700a28c44b599869745e5fda8b0c-7623-135541',
'binaryrec': '6c652ee938b3485894dbacbb8c7c2c61-5a4-38a5'}

page = recordings[recording]

self.browser.go(f"/session-recording#/{page}")

def _term_line(self, lineno):
return f".xterm-accessibility-tree div:nth-child({lineno})"

def testPlay(self):
b, _ = self._login()
self._sel_rec()
self._sel_rec('rec1')
b.click("#player-play-pause")
b.wait_in_text(self._term_line(1), "localhost")

def testPlayBinary(self):
b, _ = self._login()
self._sel_rec('binaryrec')
b.click("#player-play-pause")
time.sleep(5)
b.wait_in_text(self._term_line(21), "�")
b.wait_in_text(self._term_line(25), "exit")

def testFastforwardControls(self):
progress = ".pf-c-progress__indicator"

b, _ = self._login()
self._sel_rec()
self._sel_rec('rec1')
# fast forward
b.click("#player-fast-forward")
b.wait_in_text(self._term_line(12), "exit")
Expand All @@ -54,7 +84,7 @@ class TestApplication(MachineCase):

def testSpeedControls(self):
b, _ = self._login()
self._sel_rec()
self._sel_rec('rec1')
# increase speed
b.wait_present("#player-speed-up")
b.click("#player-speed-up")
Expand Down Expand Up @@ -98,7 +128,7 @@ class TestApplication(MachineCase):
)

b, _ = self._login()
self._sel_rec()
self._sel_rec('rec1')
# Wait for terminal with scale(1)
b.wait_present(default_scale_sel)
# Zoom in x3
Expand All @@ -117,18 +147,16 @@ class TestApplication(MachineCase):

def testSkipFrame(self):
b, _ = self._login()
self._sel_rec()
self._sel_rec('rec1')
b.wait_present(self._term_line(1))
# loop until 3 valid frames have passed
while "localhost" not in b.text(self._term_line(1)):
b.click("#player-skip-frame")
b.wait_in_text(self._term_line(1), "localhost")

def testPlaybackPause(self):
import time

b, _ = self._login()
self._sel_rec()
self._sel_rec('rec1')
# Start and pause the player
b.click("#player-restart")
b.click("#player-play-pause")
Expand All @@ -140,8 +168,6 @@ class TestApplication(MachineCase):
b.click("#player-play-pause")

def testSessionRecordingConf(self):
import time, json, configparser

b, m = self._login()
b.click("#btn-config")

Expand Down Expand Up @@ -240,7 +266,7 @@ class TestApplication(MachineCase):

def testDisplayDrag(self):
b, _ = self._login()
self._sel_rec()
self._sel_rec('rec1')
# start playback and pause in middle
b.click("#player-play-pause")
b.wait_in_text(self._term_line(1), "localhost")
Expand All @@ -259,7 +285,7 @@ class TestApplication(MachineCase):
def testLogCorrelation(self):
b, _ = self._login()
# select the recording with the extra logs
self._sel_rec(1)
self._sel_rec('rec2')
b.click("#btn-logs-view .pf-c-expandable-section__toggle")
# fast forward until the end
while "exit" not in b.text(self._term_line(22)):
Expand All @@ -272,7 +298,7 @@ class TestApplication(MachineCase):
play_scale_sel = '.console-ct[style^="transform: scale(0.4"]'
zoom_one_scale_sel = '.console-ct[style^="transform: scale(0.5"]'
b, _ = self._login()
self._sel_rec()
self._sel_rec('rec1')
# set speed x16 and begin playing, expecting a size adjustment
for _ in range(4):
b.click("#player-speed-up")
Expand All @@ -289,8 +315,6 @@ class TestApplication(MachineCase):
b.wait_present(play_scale_sel)

def _filter(self, inp, occ_dict):
import time

# ignore errors from half-entered timestamps due to searches occuring
# before `set_input_text` is complete
self.allow_journal_messages(".*timestamp.*")
Expand Down
Binary file added test/files/binary-rec.journal
Binary file not shown.

0 comments on commit 0e8f87a

Please sign in to comment.