Skip to content

Commit aa00278

Browse files
committed
pulling container logs after all other reporting is done and moving screenshotting out of a function
1 parent e2575ed commit aa00278

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

Diff for: ci/ci.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,6 @@ def create_dir():
143143
except:
144144
os.makedirs(outdir)
145145

146-
# Take a screenshot using the webdriver
147-
def take_screenshot(endpoint,container_tag):
148-
print('Taking screenshot of ' + container_tag + ' at ' + endpoint)
149-
try:
150-
requests.get(endpoint, timeout=3)
151-
driver.get(endpoint)
152-
driver.get_screenshot_as_file(outdir + container_tag + '.png')
153-
report_tests.append(['Screenshot ' + container_tag,'PASS'])
154-
except (requests.Timeout, requests.ConnectionError, KeyError) as e:
155-
report_tests.append(['Screenshot ' + container_tag,'FAIL CONNECTION ERROR'])
156-
except ErrorInResponseException as error:
157-
report_tests.append(['Screenshot ' + container_tag,'FAIL SERVER ERROR'])
158-
except TimeoutException as error:
159-
report_tests.append(['Screenshot ' + container_tag,'FAIL TIMEOUT'])
160-
except WebDriverException as error:
161-
report_tests.append(['Screenshot ' + container_tag,'FAIL UNKNOWN'])
162-
163146
# Main container test logic
164147
def container_test(tag):
165148
# Start the container
@@ -187,17 +170,6 @@ def container_test(tag):
187170
print('Startup failed for ' + tag)
188171
report_tests.append(['Startup ' + tag,'FAIL INIT NOT FINISHED'])
189172
mark_fail()
190-
if screenshot == 'true':
191-
# Sleep for the user specified amount of time
192-
time.sleep(int(testdelay))
193-
# Take a screenshot
194-
if ssl == 'true':
195-
proto = 'https://'
196-
else:
197-
proto = 'http://'
198-
container.reload()
199-
ip = container.attrs["NetworkSettings"]["Networks"]["bridge"]["IPAddress"]
200-
take_screenshot(proto + webauth + '@' + ip + ':' + port + webpath ,tag)
201173
# Dump package information
202174
print('Dumping package info for ' + tag)
203175
if base == 'alpine':
@@ -213,6 +185,32 @@ def container_test(tag):
213185
print(error)
214186
report_tests.append(['Dump Versions ' + tag,'FAIL'])
215187
mark_fail()
188+
# Screenshot web interface and check connectivity
189+
if screenshot == 'true':
190+
# Sleep for the user specified amount of time
191+
time.sleep(int(testdelay))
192+
# Take a screenshot
193+
if ssl == 'true':
194+
proto = 'https://'
195+
else:
196+
proto = 'http://'
197+
container.reload()
198+
ip = container.attrs["NetworkSettings"]["Networks"]["bridge"]["IPAddress"]
199+
endpoint = proto + webauth + '@' + ip + ':' + port + webpath
200+
print('Taking screenshot of ' + tag + ' at ' + endpoint)
201+
try:
202+
requests.get(endpoint, timeout=3)
203+
driver.get(endpoint)
204+
driver.get_screenshot_as_file(outdir + tag + '.png')
205+
report_tests.append(['Screenshot ' + tag,'PASS'])
206+
except (requests.Timeout, requests.ConnectionError, KeyError) as e:
207+
report_tests.append(['Screenshot ' + tag,'FAIL CONNECTION ERROR'])
208+
except ErrorInResponseException as error:
209+
report_tests.append(['Screenshot ' + tag,'FAIL SERVER ERROR'])
210+
except TimeoutException as error:
211+
report_tests.append(['Screenshot ' + tag,'FAIL TIMEOUT'])
212+
except WebDriverException as error:
213+
report_tests.append(['Screenshot ' + tag,'FAIL UNKNOWN'])
216214
# Grab build version
217215
try:
218216
build_version = container.attrs["Config"]["Labels"]["build_version"]
@@ -221,6 +219,8 @@ def container_test(tag):
221219
build_version = 'ERROR'
222220
report_tests.append(['Get Build Version ' + tag,'FAIL'])
223221
mark_fail()
222+
# Grab container logs for last time before destruction
223+
logblob = container.logs().decode("utf-8")
224224
# Add the info to the report
225225
report_containers.append({
226226
"tag":tag,

0 commit comments

Comments
 (0)