Skip to content

Commit a89303e

Browse files
Merge pull request #2 from punktDe/task/extend-testing
Create a PHP project during the test workflow and ensure that Roadrunner is running properly
2 parents c8ae3c5 + 7886549 commit a89303e

File tree

5 files changed

+94
-6
lines changed

5 files changed

+94
-6
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
.DS_Store
22
*.pyc
33
__pycache__
4-
files/

molecule/default/converge.yml

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
environment:
55
GITHUB_ACTIONS: "maybe"
66
vars:
7+
php:
8+
install_composer: yes
9+
roadrunner:
10+
config:
11+
main:
712
system:
813
features:
914
proserver_user: yes

molecule/default/files/app.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use Spiral\RoadRunner;
4+
use Nyholm\Psr7;
5+
6+
include "vendor/autoload.php";
7+
8+
$worker = RoadRunner\Worker::create();
9+
$psrFactory = new Psr7\Factory\Psr17Factory();
10+
11+
$worker = new RoadRunner\Http\PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);
12+
13+
while ($req = $worker->waitRequest()) {
14+
try {
15+
$rsp = new Psr7\Response();
16+
$rsp->getBody()->write('Hello world!');
17+
18+
$worker->respond($rsp);
19+
} catch (\Throwable $e) {
20+
$worker->getWorker()->error((string)$e);
21+
}
22+
}
23+
?>

molecule/default/verify.yml

+64-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,69 @@
11
---
2-
# This is an example playbook to execute Ansible tests.
3-
42
- name: Verify
53
hosts: all
64
gather_facts: false
75
tasks:
8-
- name: Example assertion
9-
ansible.builtin.assert:
10-
that: true
6+
- name: Create the current_release folder
7+
ansible.builtin.file:
8+
dest: "{{ item }}"
9+
state: "directory"
10+
owner: proserver
11+
mode: "0755"
12+
loop:
13+
- "/var/www/current"
14+
15+
- name: Initialize the composer project
16+
community.general.composer:
17+
command: init
18+
arguments: >-
19+
--name punktde/roadrunner-test
20+
--description=
21+
--type=project
22+
--author=
23+
--homepage=
24+
--no-interaction
25+
working_dir: "/var/www/current"
26+
27+
- name: Install PHP dependencies
28+
community.general.composer:
29+
command: require
30+
arguments: "{{ item }}"
31+
working_dir: "/var/www/current"
32+
loop:
33+
- "nyholm/psr7"
34+
- "spiral/roadrunner"
35+
- "spiral/roadrunner-http"
36+
37+
- name: Create the current_release public folder
38+
ansible.builtin.file:
39+
dest: "{{ item }}"
40+
state: "directory"
41+
owner: proserver
42+
mode: "0755"
43+
loop:
44+
- "/var/www/current/public"
45+
46+
- name: Copy the example PHP script
47+
ansible.builtin.copy:
48+
owner: proserver
49+
mode: "0644"
50+
src: "app.php"
51+
dest: "/var/www/current/app.php"
52+
53+
- name: Start the roadrunner-main service
54+
ansible.builtin.service:
55+
name: "roadrunner@main"
56+
state: "started"
57+
enabled: yes
58+
59+
- name: Check that a page returns successfully but fail if the word 'Hello world' is not in the page contents
60+
ansible.builtin.uri:
61+
url: http://localhost:8080
62+
return_content: true
63+
register: this
64+
retries: 3
65+
delay: 3
66+
until: not this.failed
67+
failed_when:
68+
- this is failed
69+
- "'Hello world!' not in this.content"

tasks/config-Debian.yml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
dest: "/etc/systemd/system/roadrunner@{{ roadrunner_config.key }}.service"
3030

3131
- name: Start and enable roadrunner@{{ roadrunner_config.key }}.path
32+
tags:
33+
- molecule-idempotence-notest
3234
ansible.builtin.service:
3335
daemon_reload: yes
3436
name: roadrunner@{{ roadrunner_config.key }}.service

0 commit comments

Comments
 (0)