summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--auto/modules/nodejs5
-rw-r--r--pkg/rpm/Makefile6
-rw-r--r--pkg/rpm/Makefile.go2
-rw-r--r--pkg/rpm/Makefile.perl2
-rw-r--r--pkg/rpm/Makefile.php2
-rw-r--r--pkg/rpm/Makefile.python2
-rw-r--r--pkg/rpm/Makefile.python272
-rw-r--r--pkg/rpm/Makefile.python342
-rw-r--r--pkg/rpm/Makefile.python352
-rw-r--r--pkg/rpm/Makefile.python362
-rw-r--r--pkg/rpm/Makefile.python3757
-rw-r--r--pkg/rpm/Makefile.ruby2
-rw-r--r--pkg/rpm/rpmbuild/SOURCES/unit.example-python37-config17
-rw-r--r--pkg/rpm/rpmbuild/SOURCES/unit.logrotate10
-rw-r--r--pkg/rpm/rpmbuild/SOURCES/unit.service20
-rw-r--r--pkg/rpm/rpmbuild/SOURCES/unit.sysconf2
-rw-r--r--pkg/rpm/unit.module.spec.in11
-rw-r--r--pkg/rpm/unit.spec.in49
-rw-r--r--src/nxt_main.h4
-rw-r--r--src/nxt_main_process.c29
-rwxr-xr-xtest/node/write_before_write_head/app.js1
-rw-r--r--test/perl/body_io_fake/IOFake.pm33
-rw-r--r--test/perl/body_io_fake/psgi.pl11
-rw-r--r--test/php/query_string/index.php4
-rw-r--r--test/test_configuration.py47
-rw-r--r--test/test_go_application.py7
-rw-r--r--test/test_node_application.py11
-rw-r--r--test/test_perl_application.py33
-rw-r--r--test/test_php_application.py27
-rw-r--r--test/test_python_application.py22
-rw-r--r--test/test_ruby_application.py19
-rw-r--r--test/test_tls.py20
-rw-r--r--test/unit.py10
33 files changed, 401 insertions, 72 deletions
diff --git a/auto/modules/nodejs b/auto/modules/nodejs
index e0208f5d..57bf9d3a 100644
--- a/auto/modules/nodejs
+++ b/auto/modules/nodejs
@@ -145,6 +145,8 @@ cat << END >> $NXT_MAKEFILE
.PHONY: ${NXT_NODE}-build
.PHONY: ${NXT_NODE}-publish
+NXT_UNIT_VERSION=\$(shell grep 'define NXT_VERSION' \
+ src/nxt_main.h | sed -e 's/^.*"\(.*\)".*/\1/')
${NXT_NODE}: ${NXT_NODE}-copy $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC
${NXT_NODE_EXPORTS} && \\
@@ -161,6 +163,9 @@ ${NXT_NODE_VERSION_FILE}: src/nxt_main.h
| sed -e 's/[^0-9]//g' >> $NXT_NODE_VERSION_FILE
${NXT_NODE_TARBALL}: ${NXT_NODE}-copy
+ sed -e 's/"version"\s*:.*/"version": "\$(NXT_UNIT_VERSION).0",/' \
+ ${NXT_NODE_TMP}/package.json > ${NXT_NODE_TMP}/package.json.tmp
+ mv ${NXT_NODE_TMP}/package.json.tmp ${NXT_NODE_TMP}/package.json
tar -zcvf ${NXT_NODE_TARBALL} -C ${NXT_NODE_TMP} .
diff --git a/pkg/rpm/Makefile b/pkg/rpm/Makefile
index ef7f3361..d817b434 100644
--- a/pkg/rpm/Makefile
+++ b/pkg/rpm/Makefile
@@ -89,7 +89,11 @@ endif
ifeq ($(OSVER), fedora)
include Makefile.php
include Makefile.python27
+ifeq ($(shell test `rpm --eval '0%{?fedora} -ge 29'`; echo $$?),0)
+include Makefile.python37
+else
include Makefile.python36
+endif
include Makefile.go
include Makefile.perl
include Makefile.ruby
@@ -98,7 +102,7 @@ endif
CONFIGURE_ARGS=\
--prefix=/usr \
--state=%{_sharedstatedir}/unit \
- --control="unix:/var/run/control.unit.sock" \
+ --control="unix:/var/run/unit/control.sock" \
--pid=/var/run/unit.pid \
--log=/var/log/unit.log \
--tests \
diff --git a/pkg/rpm/Makefile.go b/pkg/rpm/Makefile.go
index f031c7ba..09dffd21 100644
--- a/pkg/rpm/Makefile.go
+++ b/pkg/rpm/Makefile.go
@@ -64,7 +64,7 @@ To check the sample app, run these commands:
GOPATH=%{gopath} go build -o /tmp/go-app /usr/share/doc/unit-go/examples/go-app/let-my-people.go
sudo service unit start
cd /usr/share/doc/%{name}/examples
- sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
curl http://localhost:8500/
Online documentation is available at https://unit.nginx.org
diff --git a/pkg/rpm/Makefile.perl b/pkg/rpm/Makefile.perl
index 84c15260..f59b7353 100644
--- a/pkg/rpm/Makefile.perl
+++ b/pkg/rpm/Makefile.perl
@@ -51,7 +51,7 @@ To check out the sample app, run these commands:
sudo service unit start
cd /usr/share/doc/%{name}/examples
- sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
curl http://localhost:8600/
Online documentation is available at https://unit.nginx.org
diff --git a/pkg/rpm/Makefile.php b/pkg/rpm/Makefile.php
index eedcce4e..8f39efc0 100644
--- a/pkg/rpm/Makefile.php
+++ b/pkg/rpm/Makefile.php
@@ -46,7 +46,7 @@ To check out the sample app, run these commands:
sudo service unit start
cd /usr/share/doc/%{name}/examples
- sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
curl http://localhost:8300/
Online documentation is available at https://unit.nginx.org
diff --git a/pkg/rpm/Makefile.python b/pkg/rpm/Makefile.python
index bb408bb5..334d62c1 100644
--- a/pkg/rpm/Makefile.python
+++ b/pkg/rpm/Makefile.python
@@ -46,7 +46,7 @@ To check the sample app, run these commands:
sudo service unit start
cd /usr/share/doc/%{name}/examples
- sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
curl http://localhost:8400/
Online documentation is available at https://unit.nginx.org
diff --git a/pkg/rpm/Makefile.python27 b/pkg/rpm/Makefile.python27
index c6a2ec65..005eff17 100644
--- a/pkg/rpm/Makefile.python27
+++ b/pkg/rpm/Makefile.python27
@@ -48,7 +48,7 @@ To check the sample app, run these commands:
sudo service unit start
cd /usr/share/doc/%{name}/examples
- sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
curl http://localhost:8400/
Online documentation is available at https://unit.nginx.org
diff --git a/pkg/rpm/Makefile.python34 b/pkg/rpm/Makefile.python34
index 1dc10f9c..83c0bdb6 100644
--- a/pkg/rpm/Makefile.python34
+++ b/pkg/rpm/Makefile.python34
@@ -46,7 +46,7 @@ To check the sample app, run these commands:
sudo service unit start
cd /usr/share/doc/%{name}/examples
- sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
curl http://localhost:8400/
Online documentation is available at https://unit.nginx.org
diff --git a/pkg/rpm/Makefile.python35 b/pkg/rpm/Makefile.python35
index 3e4e0a2e..6f866771 100644
--- a/pkg/rpm/Makefile.python35
+++ b/pkg/rpm/Makefile.python35
@@ -41,7 +41,7 @@ To check the sample app, run these commands:
sudo service unit start
cd /usr/share/doc/%{name}/examples
- sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
curl http://localhost:8400/
Online documentation is available at https://unit.nginx.org
diff --git a/pkg/rpm/Makefile.python36 b/pkg/rpm/Makefile.python36
index d674d8fe..25e33968 100644
--- a/pkg/rpm/Makefile.python36
+++ b/pkg/rpm/Makefile.python36
@@ -46,7 +46,7 @@ To check the sample app, run these commands:
sudo service unit start
cd /usr/share/doc/%{name}/examples
- sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
curl http://localhost:8400/
Online documentation is available at https://unit.nginx.org
diff --git a/pkg/rpm/Makefile.python37 b/pkg/rpm/Makefile.python37
new file mode 100644
index 00000000..ed9462b8
--- /dev/null
+++ b/pkg/rpm/Makefile.python37
@@ -0,0 +1,57 @@
+MODULES+= python37
+MODULE_SUFFIX_python37= python3.7
+
+MODULE_SUMMARY_python37= Python 3.7 module for NGINX Unit
+
+MODULE_VERSION_python37= $(VERSION)
+MODULE_RELEASE_python37= 1
+
+MODULE_CONFARGS_python37= python --config=python3.7-config
+MODULE_MAKEARGS_python37= python3.7
+MODULE_INSTARGS_python37= python3.7-install
+
+MODULE_SOURCES_python37= unit.example-python-app \
+ unit.example-python37-config
+
+ifneq (,$(findstring $(OSVER),opensuse-tumbleweed sles fedora))
+BUILD_DEPENDS_python37= python3-devel
+else
+BUILD_DEPENDS_python37= python37-devel
+endif
+
+BUILD_DEPENDS+= $(BUILD_DEPENDS_python37)
+
+define MODULE_PREINSTALL_python37
+%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit-python37/examples/python-app
+%{__install} -m 644 -p %{SOURCE100} \
+ %{buildroot}%{_datadir}/doc/unit-python37/examples/python-app/wsgi.py
+%{__install} -m 644 -p %{SOURCE101} \
+ %{buildroot}%{_datadir}/doc/unit-python37/examples/unit.config
+endef
+export MODULE_PREINSTALL_python37
+
+define MODULE_FILES_python37
+%{_libdir}/unit/modules/*
+%{_libdir}/unit/debug-modules/*
+endef
+export MODULE_FILES_python37
+
+define MODULE_POST_python37
+cat <<BANNER
+----------------------------------------------------------------------
+
+The $(MODULE_SUMMARY_python37) has been installed.
+
+To check the sample app, run these commands:
+
+ sudo service unit start
+ cd /usr/share/doc/%{name}/examples
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
+ curl http://localhost:8400/
+
+Online documentation is available at https://unit.nginx.org
+
+----------------------------------------------------------------------
+BANNER
+endef
+export MODULE_POST_python37
diff --git a/pkg/rpm/Makefile.ruby b/pkg/rpm/Makefile.ruby
index 92416338..51c2949d 100644
--- a/pkg/rpm/Makefile.ruby
+++ b/pkg/rpm/Makefile.ruby
@@ -55,7 +55,7 @@ To check the sample app, run these commands:
sudo service unit start
cd /usr/share/doc/%{name}/examples
- sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/control.unit.sock http://localhost/config
+ sudo curl -X PUT --data-binary @unit.config --unix-socket /var/run/unit/control.sock http://localhost/config
curl http://localhost:8700/
Online documentation is available at https://unit.nginx.org
diff --git a/pkg/rpm/rpmbuild/SOURCES/unit.example-python37-config b/pkg/rpm/rpmbuild/SOURCES/unit.example-python37-config
new file mode 100644
index 00000000..ada7ae5b
--- /dev/null
+++ b/pkg/rpm/rpmbuild/SOURCES/unit.example-python37-config
@@ -0,0 +1,17 @@
+{
+ "applications": {
+ "example_python": {
+ "type": "python 3.7",
+ "user": "nobody",
+ "processes": 2,
+ "path": "/usr/share/doc/unit-python37/examples/python-app",
+ "module": "wsgi"
+ }
+ },
+
+ "listeners": {
+ "*:8400": {
+ "application": "example_python"
+ }
+ }
+}
diff --git a/pkg/rpm/rpmbuild/SOURCES/unit.logrotate b/pkg/rpm/rpmbuild/SOURCES/unit.logrotate
new file mode 100644
index 00000000..8fb00199
--- /dev/null
+++ b/pkg/rpm/rpmbuild/SOURCES/unit.logrotate
@@ -0,0 +1,10 @@
+/var/log/unit/*.log {
+ missingok
+ nocreate
+ notifempty
+ postrotate
+ if [ -f /var/run/unit/unit.pid ]; then
+ /bin/kill -SIGUSR1 `cat /var/run/unit/unit.pid`
+ fi
+ endscript
+}
diff --git a/pkg/rpm/rpmbuild/SOURCES/unit.service b/pkg/rpm/rpmbuild/SOURCES/unit.service
index 4aaf70cd..f888685f 100644
--- a/pkg/rpm/rpmbuild/SOURCES/unit.service
+++ b/pkg/rpm/rpmbuild/SOURCES/unit.service
@@ -1,14 +1,26 @@
+# Modifying this file in-place is not recommended, because changes
+# will be overwritten during package upgrades. To customize the
+# behaviour, run "systemctl edit unit" to create an override unit.
+
+# For example, to change options given to the unitd binary at startup,
+# create an override unit (as is done by systemctl edit) and enter
+# the following:
+
+# [Service]
+# Environment="UNITD_OPTIONS=--log /var/log/unit/unit.log --pid /run/unit/unit.pid"
+
[Unit]
Description=NGINX Unit
Wants=network-online.target
After=network-online.target
[Service]
-Type=forking
-PIDFile=/run/unit.pid
-EnvironmentFile=-/etc/sysconfig/unit
-ExecStart=/usr/sbin/unitd $UNITD_OPTIONS
+Type=simple
+Environment="UNITD_OPTIONS=--log /var/log/unit/unit.log --pid /run/unit/unit.pid"
+ExecStart=/usr/sbin/unitd $UNITD_OPTIONS --no-daemon
ExecReload=
+RuntimeDirectory=unit
+RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
diff --git a/pkg/rpm/rpmbuild/SOURCES/unit.sysconf b/pkg/rpm/rpmbuild/SOURCES/unit.sysconf
index 0b28558f..9146bdac 100644
--- a/pkg/rpm/rpmbuild/SOURCES/unit.sysconf
+++ b/pkg/rpm/rpmbuild/SOURCES/unit.sysconf
@@ -1 +1 @@
-UNITD_OPTIONS="--log /var/log/unit.log --pid /run/unit.pid"
+UNITD_OPTIONS="--log /var/log/unit/unit.log --pid /var/run/unit/unit.pid"
diff --git a/pkg/rpm/unit.module.spec.in b/pkg/rpm/unit.module.spec.in
index 03d4addb..8b8a3433 100644
--- a/pkg/rpm/unit.module.spec.in
+++ b/pkg/rpm/unit.module.spec.in
@@ -44,6 +44,10 @@ This package contains %%SUMMARY%%.
%debug_package
%endif
+%if 0%{?fedora}
+%define _debugsource_template %{nil}
+%endif
+
%prep
%setup -qcTn %{name}-%{unit_version}
tar --strip-components=1 -zxf %{SOURCE0}
@@ -78,6 +82,13 @@ DESTDIR=%{buildroot} make %%MODULE_INSTARGS%%
DESTDIR=%{buildroot} make %%MODULE_INSTARGS%%
%check
+%{__rm} -rf %{buildroot}/usr/src
+cd %{bdir}
+grep -v 'usr/src' debugfiles.list > debugfiles.list.new && mv debugfiles.list.new debugfiles.list
+cat /dev/null > debugsources.list
+%if 0%{?suse_version} >= 1500
+cat /dev/null > debugsourcefiles.list
+%endif
%clean
%{__rm} -rf %{buildroot}
diff --git a/pkg/rpm/unit.spec.in b/pkg/rpm/unit.spec.in
index 1ef02881..05ee79af 100644
--- a/pkg/rpm/unit.spec.in
+++ b/pkg/rpm/unit.spec.in
@@ -1,25 +1,31 @@
# distribution specific definitions
-%define use_systemd (0%{?rhel} && 0%{?rhel} >= 7) || (0%{?suse_version} >= 1315)
+%define use_systemd (0%{?rhel} >= 7 || 0%{?fedora} >= 19 || 0%{?suse_version} >= 1315)
%define bdir %{_builddir}/%{name}-%{version}
%define dotests 0
%if ( 0%{?rhel} == 5 || 0%{?rhel} == 6 )
Requires: initscripts >= 8.36
-BuildRequires: openssl-devel
%endif
-%if 0%{?rhel} == 7
-Requires: systemd
-BuildRequires: systemd-units
+%if %{use_systemd}
+BuildRequires: systemd
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+%endif
+
+%if 0%{?rhel}%{?fedora}
+BuildRequires: gcc
BuildRequires: openssl-devel
+%endif
+
+%if 0%{?rhel}
%if 0%{?amzn} == 0
-%define dist .el7
+%define dist .el%{?rhel}
%endif
%endif
%if 0%{?suse_version} >= 1315
-BuildRequires: systemd
-Requires: systemd
BuildRequires: libopenssl-devel
%endif
@@ -45,6 +51,7 @@ Source1: unit.service
Source2: unit.init
Source3: unit.sysconf
Source4: unit.example.config
+Source5: unit.logrotate
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -60,6 +67,10 @@ dynamically via an API.
%debug_package
%endif
+%if 0%{?fedora}
+%define _debugsource_template %{nil}
+%endif
+
%package devel
Summary: NGINX Unit (development files)
Version: %%VERSION%%
@@ -103,9 +114,16 @@ DESTDIR=%{buildroot} make unitd-install libunit-install
%{__mkdir} -p %{buildroot}%{_libdir}/unit/modules
%{__mkdir} -p %{buildroot}%{_libdir}/unit/debug-modules
%{__mkdir} -p %{buildroot}%{_sharedstatedir}/unit
+%{__mkdir} -p %{buildroot}%{_localstatedir}/log/unit
+%{__mkdir} -p %{buildroot}%{_localstatedir}/run/unit
+%if ! %{use_systemd}
%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
%{__install} -m 644 -p %{SOURCE3} \
- %{buildroot}%{_sysconfdir}/sysconfig/unit
+ %{buildroot}%{_sysconfdir}/sysconfig/unitd
+%endif
+%{__mkdir} -p %{buildroot}%{_sysconfdir}/logrotate.d
+%{__install} -m 644 -p %{SOURCE5} \
+ %{buildroot}%{_sysconfdir}/logrotate.d/unit
%{__mkdir} -p %{buildroot}%{_sysconfdir}/unit
%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples
%{__install} -m 644 -p %{SOURCE4} \
@@ -133,6 +151,13 @@ export QA_SKIP_BUILD_ROOT
%if %{dotests}
cd %{bdir} && make tests && ./build/tests
%endif
+%{__rm} -rf %{buildroot}/usr/src
+cd %{bdir}
+grep -v 'usr/src' debugfiles.list > debugfiles.list.new && mv debugfiles.list.new debugfiles.list
+cat /dev/null > debugsources.list
+%if 0%{?suse_version} >= 1500
+cat /dev/null > debugsourcefiles.list
+%endif
%clean
%{__rm} -rf %{buildroot}
@@ -185,11 +210,13 @@ fi
%defattr(-,root,root,-)
%attr(0755,root,root) %{_sbindir}/unitd
%attr(0755,root,root) %{_sbindir}/unitd-debug
-%config(noreplace) %{_sysconfdir}/sysconfig/unit
%dir %{_sysconfdir}/unit
%if %{use_systemd}
%{_unitdir}/unit.service
+%dir %attr(0755,root,root) %ghost %{_localstatedir}/run/unit
%else
+%config(noreplace) %{_sysconfdir}/sysconfig/unitd
+%dir %attr(0755,root,root) %{_localstatedir}/run/unit
%{_initrddir}/unit
%endif
%dir %{_datadir}/doc/unit
@@ -197,6 +224,8 @@ fi
%dir %{_libdir}/unit/modules
%dir %{_libdir}/unit/debug-modules
%dir %{_sharedstatedir}/unit
+%dir %attr(0700,root,root) %{_localstatedir}/log/unit
+%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%files devel
%{_libdir}/libunit.a
diff --git a/src/nxt_main.h b/src/nxt_main.h
index 760384ea..dc821e07 100644
--- a/src/nxt_main.h
+++ b/src/nxt_main.h
@@ -11,8 +11,8 @@
#include <nxt_auto_config.h>
-#define NXT_VERSION "1.7.1"
-#define NXT_VERNUM 10701
+#define NXT_VERSION "1.8"
+#define NXT_VERNUM 10800
#define NXT_SERVER "Unit/" NXT_VERSION
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c
index 819ed44c..a4c3f119 100644
--- a/src/nxt_main_process.c
+++ b/src/nxt_main_process.c
@@ -1116,24 +1116,23 @@ nxt_main_listening_socket(nxt_sockaddr_t *sa, nxt_listening_socket_t *ls)
break;
}
- goto next;
- }
-
+ } else
#endif
+ {
+ switch (err) {
- switch (err) {
-
- case EACCES:
- ls->error = NXT_SOCKET_ERROR_PORT;
- break;
+ case EACCES:
+ ls->error = NXT_SOCKET_ERROR_PORT;
+ break;
- case EADDRINUSE:
- ls->error = NXT_SOCKET_ERROR_INUSE;
- break;
+ case EADDRINUSE:
+ ls->error = NXT_SOCKET_ERROR_INUSE;
+ break;
- case EADDRNOTAVAIL:
- ls->error = NXT_SOCKET_ERROR_NOADDR;
- break;
+ case EADDRNOTAVAIL:
+ ls->error = NXT_SOCKET_ERROR_NOADDR;
+ break;
+ }
}
ls->end = nxt_sprintf(ls->start, ls->end, "bind(\\\"%*s\\\") failed %E",
@@ -1143,8 +1142,6 @@ nxt_main_listening_socket(nxt_sockaddr_t *sa, nxt_listening_socket_t *ls)
#if (NXT_HAVE_UNIX_DOMAIN)
-next:
-
if (sa->u.sockaddr.sa_family == AF_UNIX) {
char *filename;
mode_t access;
diff --git a/test/node/write_before_write_head/app.js b/test/node/write_before_write_head/app.js
index 9fe3a58d..6e3fb9a9 100755
--- a/test/node/write_before_write_head/app.js
+++ b/test/node/write_before_write_head/app.js
@@ -3,4 +3,5 @@
require('unit-http').createServer(function (req, res) {
res.write('blah');
res.writeHead(200, {'Content-Type': 'text/plain'});
+ res.end();
}).listen(7080);
diff --git a/test/perl/body_io_fake/IOFake.pm b/test/perl/body_io_fake/IOFake.pm
new file mode 100644
index 00000000..d2542aa5
--- /dev/null
+++ b/test/perl/body_io_fake/IOFake.pm
@@ -0,0 +1,33 @@
+package IOFake;
+
+sub new {
+ my $class = shift;
+ my $errors = shift;
+ my $self = {};
+
+ $self->{_count} = 2;
+ $self->{_errors} = $errors;
+
+ bless $self, $class;
+ return $self;
+}
+
+sub getline() {
+ my $self = shift;
+
+ if ($self->{_count} > 0) {
+ return $self->{_count}--;
+ }
+
+ $self->{_errors}->print('IOFake getline() $/ is ' . ${ $/ });
+
+ return;
+}
+
+sub close() {
+ my $self = shift;
+
+ $self->{_errors}->print('IOFake close() called');
+};
+
+1;
diff --git a/test/perl/body_io_fake/psgi.pl b/test/perl/body_io_fake/psgi.pl
new file mode 100644
index 00000000..6990bfaf
--- /dev/null
+++ b/test/perl/body_io_fake/psgi.pl
@@ -0,0 +1,11 @@
+use File::Basename;
+use lib dirname (__FILE__);
+use IOFake;
+
+my $app = sub {
+ my ($environ) = @_;
+
+ my $io = IOFake->new($environ->{'psgi.errors'});
+
+ return ['200', [ 'Content-Length' => '2' ], $io];
+};
diff --git a/test/php/query_string/index.php b/test/php/query_string/index.php
new file mode 100644
index 00000000..5691324d
--- /dev/null
+++ b/test/php/query_string/index.php
@@ -0,0 +1,4 @@
+<?php
+header('Content-Length: 0');
+header('Query-String: ' . $_SERVER['QUERY_STRING']);
+?>
diff --git a/test/test_configuration.py b/test/test_configuration.py
index 02705afe..7f81b86b 100644
--- a/test/test_configuration.py
+++ b/test/test_configuration.py
@@ -217,5 +217,52 @@ class TestUnitConfiguration(unit.TestUnitControl):
}
}), 'no port')
+ @unittest.expectedFailure
+ def test_json_application_name_large(self):
+ self.skip_alerts.append(r'epoll_ctl.+failed')
+ name = "X" * 1024 * 1024
+
+ self.assertIn('success', self.conf({
+ "listeners": {
+ "*:7080": {
+ "application": name
+ }
+ },
+ "applications": {
+ name: {
+ "type": "python",
+ "processes": { "spare": 0 },
+ "path": "/app",
+ "module": "wsgi"
+ }
+ }
+ }))
+
+ @unittest.expectedFailure
+ def test_json_application_many(self):
+ self.skip_alerts.extend([
+ r'eventfd.+failed',
+ r'failed to apply new conf'
+ ])
+ apps = 1000
+
+ conf = {
+ "applications":
+ {"app-" + str(a): {
+ "type": "python",
+ "processes": { "spare": 0 },
+ "path": "/app",
+ "module": "wsgi"
+ } for a in range(apps)
+ },
+ "listeners": {
+ "*:" + str(7080 + a): {
+ "application": "app-" + str(a)
+ } for a in range(apps)
+ }
+ }
+
+ self.assertIn('success', self.conf(conf))
+
if __name__ == '__main__':
TestUnitConfiguration.main()
diff --git a/test/test_go_application.py b/test/test_go_application.py
index fd80bf5b..90785851 100644
--- a/test/test_go_application.py
+++ b/test/test_go_application.py
@@ -4,12 +4,7 @@ import unit
class TestUnitGoApplication(unit.TestUnitApplicationGo):
def setUpClass():
- u = unit.TestUnit()
-
- if u.architecture == '32bit':
- raise unittest.SkipTest('Skip Go tests for x86')
-
- u.check_modules('go')
+ unit.TestUnit().check_modules('go')
def test_go_application_variables(self):
self.load('variables')
diff --git a/test/test_node_application.py b/test/test_node_application.py
index 5dedb5a3..05b518f5 100644
--- a/test/test_node_application.py
+++ b/test/test_node_application.py
@@ -112,7 +112,6 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertEqual(self.get()['body'], '6\r\nbuffer\r\n0\r\n\r\n',
'write buffer')
- @unittest.expectedFailure
def test_node_application_write_callback(self):
self.load('write_callback')
@@ -121,11 +120,10 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertTrue(self.waitforfiles(self.testdir + '/node/callback'),
'write callback')
- def test_node_application_write_before_writeHead(self):
- self.skip_alerts.append(r'process \d+ exited on signal')
+ def test_node_application_write_before_write_head(self):
self.load('write_before_write_head')
- self.get()
+ self.assertEqual(self.get()['status'], 200, 'write before writeHead')
def test_node_application_double_end(self):
self.load('double_end')
@@ -182,7 +180,6 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertEqual(self.get()['headers']['X-Type'], 'number',
'get header type')
- @unittest.expectedFailure
def test_node_application_header_name_case(self):
self.load('header_name_case')
@@ -202,9 +199,7 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertTrue(self.waitforfiles(self.testdir + '/node/callback'),
'promise handler')
- @unittest.expectedFailure
def test_node_application_promise_handler_write_after_end(self):
- self.skip_alerts.append(r'process \d+ exited on signal')
self.load('promise_handler')
self.assertEqual(self.post(headers={
@@ -249,13 +244,11 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertNotIn('status', self.get(), 'header name valid')
- @unittest.expectedFailure
def test_node_application_header_value_object(self):
self.load('header_value_object')
self.assertIn('X-Header', self.get()['headers'], 'header value object')
- @unittest.expectedFailure
def test_node_application_get_header_names(self):
self.load('get_header_names')
diff --git a/test/test_perl_application.py b/test/test_perl_application.py
index c9cb3f0c..7850e231 100644
--- a/test/test_perl_application.py
+++ b/test/test_perl_application.py
@@ -55,6 +55,25 @@ class TestUnitPerlApplication(unit.TestUnitApplicationPerl):
self.assertEqual(resp['headers']['Query-String'], 'var1=val1&var2=val2',
'Query-String header')
+ def test_perl_application_query_string_empty(self):
+ self.load('query_string')
+
+ resp = self.get(url='/?')
+
+ self.assertEqual(resp['status'], 200, 'query string empty status')
+ self.assertEqual(resp['headers']['Query-String'], '',
+ 'query string empty')
+
+ @unittest.expectedFailure
+ def test_perl_application_query_string_absent(self):
+ self.load('query_string')
+
+ resp = self.get()
+
+ self.assertEqual(resp['status'], 200, 'query string absent status')
+ self.assertEqual(resp['headers']['Query-String'], '',
+ 'query string absent')
+
@unittest.expectedFailure
def test_perl_application_server_port(self):
self.load('server_port')
@@ -166,5 +185,19 @@ class TestUnitPerlApplication(unit.TestUnitApplicationPerl):
self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
+ @unittest.expectedFailure
+ def test_perl_body_io_fake(self):
+ self.load('body_io_fake')
+
+ self.assertEqual(self.get()['body'], '21', 'body io fake')
+
+ self.assertIsNotNone(
+ self.search_in_log(r'\[error\].+IOFake getline\(\) \$\/ is \d+'),
+ 'body io fake $/ value')
+
+ self.assertIsNotNone(
+ self.search_in_log(r'\[error\].+IOFake close\(\) called'),
+ 'body io fake close')
+
if __name__ == '__main__':
TestUnitPerlApplication.main()
diff --git a/test/test_php_application.py b/test/test_php_application.py
index e0058d9a..ba9c03b3 100644
--- a/test/test_php_application.py
+++ b/test/test_php_application.py
@@ -48,6 +48,33 @@ class TestUnitPHPApplication(unit.TestUnitApplicationPHP):
}, 'headers')
self.assertEqual(resp['body'], body, 'body')
+ def test_php_application_query_string(self):
+ self.load('query_string')
+
+ resp = self.get(url='/?var1=val1&var2=val2')
+
+ self.assertEqual(resp['headers']['Query-String'], 'var1=val1&var2=val2',
+ 'query string')
+
+ def test_php_application_query_string_empty(self):
+ self.load('query_string')
+
+ resp = self.get(url='/?')
+
+ self.assertEqual(resp['status'], 200, 'query string empty status')
+ self.assertEqual(resp['headers']['Query-String'], '',
+ 'query string empty')
+
+ @unittest.expectedFailure
+ def test_php_application_query_string_absent(self):
+ self.load('query_string')
+
+ resp = self.get()
+
+ self.assertEqual(resp['status'], 200, 'query string absent status')
+ self.assertEqual(resp['headers']['Query-String'], '',
+ 'query string absent')
+
def test_php_application_phpinfo(self):
self.load('phpinfo')
diff --git a/test/test_python_application.py b/test/test_python_application.py
index 667047bc..b28675f9 100644
--- a/test/test_python_application.py
+++ b/test/test_python_application.py
@@ -1,3 +1,4 @@
+import time
import unittest
import unit
@@ -53,6 +54,25 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython):
self.assertEqual(resp['headers']['Query-String'], 'var1=val1&var2=val2',
'Query-String header')
+ def test_python_application_query_string_empty(self):
+ self.load('query_string')
+
+ resp = self.get(url='/?')
+
+ self.assertEqual(resp['status'], 200, 'query string empty status')
+ self.assertEqual(resp['headers']['Query-String'], '',
+ 'query string empty')
+
+ @unittest.expectedFailure
+ def test_python_application_query_string_absent(self):
+ self.load('query_string')
+
+ resp = self.get()
+
+ self.assertEqual(resp['status'], 200, 'query string absent status')
+ self.assertEqual(resp['headers']['Query-String'], '',
+ 'query string absent')
+
@unittest.expectedFailure
def test_python_application_server_port(self):
self.load('server_port')
@@ -86,6 +106,8 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython):
self.stop()
+ time.sleep(0.2)
+
self.assertIsNotNone(self.search_in_log(r'RuntimeError'),
'ctx iter atexit')
diff --git a/test/test_ruby_application.py b/test/test_ruby_application.py
index 57ab88cd..b88e043d 100644
--- a/test/test_ruby_application.py
+++ b/test/test_ruby_application.py
@@ -56,6 +56,25 @@ class TestUnitRubyApplication(unit.TestUnitApplicationRuby):
self.assertEqual(resp['headers']['Query-String'], 'var1=val1&var2=val2',
'Query-String header')
+ def test_ruby_application_query_string_empty(self):
+ self.load('query_string')
+
+ resp = self.get(url='/?')
+
+ self.assertEqual(resp['status'], 200, 'query string empty status')
+ self.assertEqual(resp['headers']['Query-String'], '',
+ 'query string empty')
+
+ @unittest.expectedFailure
+ def test_ruby_application_query_string_absent(self):
+ self.load('query_string')
+
+ resp = self.get()
+
+ self.assertEqual(resp['status'], 200, 'query string absent status')
+ self.assertEqual(resp['headers']['Query-String'], '',
+ 'query string absent')
+
@unittest.expectedFailure
def test_ruby_application_server_port(self):
self.load('server_port')
diff --git a/test/test_tls.py b/test/test_tls.py
index fa5c9754..dc2f4505 100644
--- a/test/test_tls.py
+++ b/test/test_tls.py
@@ -306,23 +306,25 @@ basicConstraints = critical,CA:TRUE""" % {
self.assertEqual(self.get_ssl()['status'], 200,
'certificate chain intermediate server')
+ @unittest.expectedFailure
def test_tls_reconfigure(self):
self.load('empty')
self.certificate()
- (resp, sock) = self.http(b"""GET / HTTP/1.1
-""", start=True, raw=True, no_recv=True)
-
- self.add_tls()
+ (resp, sock) = self.get(headers={
+ 'Connection': 'keep-alive',
+ 'Host': 'localhost'
+ }, start=True)
- resp = self.http(b"""Host: localhost
-Connection: close
+ self.assertEqual(resp['status'], 200, 'initial status')
-""", sock=sock, raw=True)
+ self.add_tls()
- self.assertEqual(resp['status'], 200, 'update status')
- self.assertEqual(self.get_ssl()['status'], 200, 'update tls status')
+ self.assertEqual(self.get(sock=sock)['status'], 200,
+ 'reconfigure status')
+ self.assertEqual(self.get_ssl()['status'], 200,
+ 'reconfigure tls status')
def test_tls_keepalive(self):
self.load('mirror')
diff --git a/test/unit.py b/test/unit.py
index e88ed684..55b3ce18 100644
--- a/test/unit.py
+++ b/test/unit.py
@@ -285,7 +285,6 @@ class TestUnitHTTP(TestUnit):
port = 7080 if 'port' not in kwargs else kwargs['port']
url = '/' if 'url' not in kwargs else kwargs['url']
http = 'HTTP/1.0' if 'http_10' in kwargs else 'HTTP/1.1'
- blocking = False if 'blocking' not in kwargs else kwargs['blocking']
headers = ({
'Host': 'localhost',
@@ -309,6 +308,9 @@ class TestUnitHTTP(TestUnit):
if 'sock' not in kwargs:
sock = socket.socket(sock_types[sock_type], socket.SOCK_STREAM)
+ if sock_type == sock_types['ipv4'] or sock_type == sock_types['ipv6']:
+ sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
+
if 'wrapper' in kwargs:
sock = kwargs['wrapper'](sock)
@@ -319,8 +321,6 @@ class TestUnitHTTP(TestUnit):
sock.close()
return None
- sock.setblocking(blocking)
-
else:
sock = kwargs['sock']
@@ -637,11 +637,11 @@ class TestUnitApplicationTLS(TestUnitApplicationProto):
return self.conf(k.read() + c.read(), '/certificates/' + crt)
def get_ssl(self, **kwargs):
- return self.get(blocking=True, wrapper=self.context.wrap_socket,
+ return self.get(wrapper=self.context.wrap_socket,
**kwargs)
def post_ssl(self, **kwargs):
- return self.post(blocking=True, wrapper=self.context.wrap_socket,
+ return self.post(wrapper=self.context.wrap_socket,
**kwargs)
def get_server_certificate(self, addr=('127.0.0.1', 7080)):