diff --git a/composer.json b/composer.json
index 32d6883607..e43fde2951 100644
--- a/composer.json
+++ b/composer.json
@@ -25,6 +25,7 @@
},
"scripts": {
"test": "pest",
+ "test-e2e": "pest --config test/e2e/phpunit-e2e.xml.dist",
"lint": "phpcs"
},
"bin": [
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index f2a50f3739..59d8be4e42 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -17,8 +17,5 @@
test/joy/
-
- test/e2e/
-
diff --git a/docker/Dockerfile b/test/docker/Dockerfile
similarity index 76%
rename from docker/Dockerfile
rename to test/docker/Dockerfile
index 0fd355a5a3..68c33623d5 100644
--- a/docker/Dockerfile
+++ b/test/docker/Dockerfile
@@ -19,6 +19,9 @@ RUN ssh-keygen \
-t rsa \
-f ~/.ssh/id_rsa
+RUN git config --global user.email "e2e@deployer.test" \
+ && git config --global user.name "E2E Deployer"
+
ARG XDEBUG_VERSION=2.9.8
RUN set -eux; \
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
@@ -27,7 +30,6 @@ RUN set -eux; \
apk del .build-deps
COPY --from=composer /tmp/composer /bin/composer
-ENV E2E_ENV=1
VOLUME [ "/project" ]
WORKDIR /project
@@ -47,8 +49,8 @@ RUN mkdir /run/sshd \
&& sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
# Configure Apache to expose healthcheck & configure site to use /var/www/html/current ad document root
-COPY ./conf/healthcheck.conf /etc/apache2/sites-available/healthcheck.conf
-COPY ./initial-site/index.html /var/www/html/initial-site/index.html
+COPY conf/healthcheck.conf /etc/apache2/sites-available/healthcheck.conf
+COPY initial-site/index.html /var/www/html/initial-site/index.html
ENV APACHE_DOCUMENT_ROOT /var/www/html/current
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/000-default.conf \
@@ -70,12 +72,25 @@ RUN useradd \
&& chmod 700 ~deployer/.ssh \
&& chmod 600 ~deployer/.ssh/authorized_keys
-COPY ./scripts/start-servers.sh /usr/local/bin/start-servers
+RUN useradd \
+ --create-home \
+ git \
+ && mkdir ~git/.ssh \
+ && touch ~git/.ssh/authorized_keys \
+ && chown -R git:git ~git/.ssh \
+ && chmod 700 ~git/.ssh \
+ && chmod 700 ~git/.ssh/authorized_keys \
+ && mkdir ~git/repository \
+ && git init --bare ~git/repository \
+ && chown -R git:git ~git/repository
+
+COPY scripts/start-servers.sh /usr/local/bin/start-servers
COPY --from=composer /tmp/composer /usr/local/bin/composer
COPY --from=deployer /root/.ssh/id_rsa.pub /tmp/root_rsa.pub
RUN chmod a+x /usr/local/bin/start-servers \
&& cat /tmp/root_rsa.pub >> ~deployer/.ssh/authorized_keys \
+ && cat /tmp/root_rsa.pub >> ~git/.ssh/authorized_keys \
&& rm -rf /tmp/root_rsa.pub
EXPOSE 22 80 81
diff --git a/docker/README.md b/test/docker/README.md
similarity index 100%
rename from docker/README.md
rename to test/docker/README.md
diff --git a/docker/conf/healthcheck.conf b/test/docker/conf/healthcheck.conf
similarity index 100%
rename from docker/conf/healthcheck.conf
rename to test/docker/conf/healthcheck.conf
diff --git a/docker/docker-compose.yml b/test/docker/docker-compose.yml
similarity index 89%
rename from docker/docker-compose.yml
rename to test/docker/docker-compose.yml
index ba906bc1a1..a6976ac86b 100644
--- a/docker/docker-compose.yml
+++ b/test/docker/docker-compose.yml
@@ -3,14 +3,14 @@ version: '2.4'
services:
deployer:
build:
- context: .
+ context: ""
target: deployer
depends_on:
server:
condition: service_healthy
volumes:
- - ./../:/project
- command: "php vendor/bin/pest"
+ - ./../../:/project
+ command: "php vendor/bin/pest --config test/e2e/phpunit-e2e.xml.dist"
networks:
- e2e
# environment:
@@ -29,7 +29,7 @@ services:
server:
build:
- context: .
+ context: ""
target: server
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:81/health_check"]
diff --git a/docker/initial-site/index.html b/test/docker/initial-site/index.html
similarity index 100%
rename from docker/initial-site/index.html
rename to test/docker/initial-site/index.html
diff --git a/docker/scripts/install-composer.sh b/test/docker/scripts/install-composer.sh
similarity index 100%
rename from docker/scripts/install-composer.sh
rename to test/docker/scripts/install-composer.sh
diff --git a/docker/scripts/start-servers.sh b/test/docker/scripts/start-servers.sh
similarity index 100%
rename from docker/scripts/start-servers.sh
rename to test/docker/scripts/start-servers.sh
diff --git a/test/e2e/AbstractE2ETest.php b/test/e2e/AbstractE2ETest.php
index 0a422e4428..b1d2e989ba 100644
--- a/test/e2e/AbstractE2ETest.php
+++ b/test/e2e/AbstractE2ETest.php
@@ -1,17 +1,50 @@
markTestSkipped('Cannot execute in non-E2E environment');
+ protected static function cleanUp(): void
+ {
+ if (is_dir(__TEMP_DIR__)) {
+ exec('rm -rf ' . __TEMP_DIR__);
}
}
+
+ protected function init(string $recipe): void
+ {
+ $console = new Application();
+ $console->setAutoExit(false);
+ $this->tester = new ApplicationTester($console);
+
+ $this->deployer = new Deployer($console);
+ Deployer::load($recipe);
+ $this->deployer->init();
+ $this->deployer->config->set('deploy_path', __TEMP_DIR__ . '/{{hostname}}');
+ }
}
diff --git a/test/e2e/FunctionsE2ETest.php b/test/e2e/FunctionsE2ETest.php
index 9f850e282d..db2966dfa1 100644
--- a/test/e2e/FunctionsE2ETest.php
+++ b/test/e2e/FunctionsE2ETest.php
@@ -19,9 +19,8 @@ public function testRunWithPlaceholders(): void
]);
$display = $this->tester->getDisplay();
- $display = trim($display); // Output may contain newlines, so we should trim them in advance
self::assertEquals(0, $this->tester->getStatusCode(), $display);
- self::assertEquals('placeholder {{bar}} xyz%', $display);
+ self::assertStringContainsString('placeholder {{bar}} xyz%', $display);
}
}
diff --git a/test/e2e/bootstrap.php b/test/e2e/bootstrap.php
new file mode 100644
index 0000000000..897a731f96
--- /dev/null
+++ b/test/e2e/bootstrap.php
@@ -0,0 +1,22 @@
+
+
+
+
+ .
+
+
+
diff --git a/test/e2e/recipe/laravel.php b/test/e2e/recipe/laravel.php
new file mode 100644
index 0000000000..e05a4f03e9
--- /dev/null
+++ b/test/e2e/recipe/laravel.php
@@ -0,0 +1,3 @@
+