summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2020-07-28 04:53:40 +0100
committerAndrei Zeliankou <zelenkov@nginx.com>2020-07-28 04:53:40 +0100
commitf1e445bdef64ceba047d07b05d1b78137ddc2a7a (patch)
tree7c772b1cdbfc5736180e3f36b1c3d892749cdf3d
parent355ed9697d10f163f4b96bc459f9c402aefa5d55 (diff)
downloadunit-f1e445bdef64ceba047d07b05d1b78137ddc2a7a.tar.gz
unit-f1e445bdef64ceba047d07b05d1b78137ddc2a7a.tar.bz2
Tests: added PHP test with time check in error log messages.
-rw-r--r--test/php/error_log/index.php3
-rw-r--r--test/test_php_application.py26
2 files changed, 29 insertions, 0 deletions
diff --git a/test/php/error_log/index.php b/test/php/error_log/index.php
new file mode 100644
index 00000000..fd90adfe
--- /dev/null
+++ b/test/php/error_log/index.php
@@ -0,0 +1,3 @@
+<?php
+error_log("Error in application");
+?>
diff --git a/test/test_php_application.py b/test/test_php_application.py
index 1259d22d..d8bfade2 100644
--- a/test/test_php_application.py
+++ b/test/test_php_application.py
@@ -1,5 +1,7 @@
import os
+import re
import shutil
+import time
import unittest
from unit.applications.lang.php import TestApplicationPHP
@@ -488,6 +490,30 @@ class TestPHPApplication(TestApplicationPHP):
self.get()['body'], r'012345', 'disable_classes before'
)
+ def test_php_application_error_log(self):
+ self.load('error_log')
+
+ self.assertEqual(self.get()['status'], 200, 'status')
+
+ time.sleep(1)
+
+ self.assertEqual(self.get()['status'], 200, 'status 2')
+
+ self.stop()
+
+ pattern = r'\d{4}\/\d\d\/\d\d\s\d\d:.+\[notice\].+Error in application'
+
+ self.assertIsNotNone(self.wait_for_record(pattern), 'errors print')
+
+ with open(self.testdir + '/unit.log', 'r', errors='ignore') as f:
+ errs = re.findall(pattern, f.read())
+
+ self.assertEqual(len(errs), 2, 'error_log count')
+
+ date = errs[0].split('[')[0]
+ date2 = errs[1].split('[')[0]
+ self.assertNotEqual(date, date2, 'date diff')
+
def test_php_application_script(self):
self.assertIn(
'success',