Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 8b99a90

Browse files
authored
Merge pull request #85 from magento/running-tests
Support running tests in cluster from PhpStorm #77
2 parents 81d73f2 + df951c7 commit 8b99a90

File tree

10 files changed

+53
-37
lines changed

10 files changed

+53
-37
lines changed
6.46 KB
Loading

docs/running-tests/running-tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
It is possible to run Magento tests using remote PHP interpreter from the kubernetes cluster.
44

5-
1. Configure remote PHP interpreter in PhpStorm with credentials `root:123123q`. Use the IP which you get by running `minikube ip` and port `30022`
5+
1. Configure remote PHP interpreter in PhpStorm with credentials `root:123123q`. Use the IP which you get by running `minikube ip` and port `30022`. It is important to update `Configuration options` field for XDebug to work.
66
![](configure-remote-php.png)
77
1. Select configured remote PHP interpreter
88
![](select-remote-php.png)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM magento2-monolith:dev-xdebug
2+
3+
RUN apt-get update && apt-get install -y openssh-server
4+
RUN mkdir /var/run/sshd
5+
RUN echo 'root:123123q' | chpasswd
6+
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
7+
8+
# SSH login fix. Otherwise user is kicked off after login
9+
RUN sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
10+
11+
ENV NOTVISIBLE "in users profile"
12+
RUN echo "export VISIBLE=now" >> /etc/profile
13+
14+
EXPOSE 22
15+
CMD ["/usr/sbin/sshd", "-D"]

etc/docker/monolith-with-xdebug/Dockerfile

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ FROM magento2-monolith:dev
22

33
RUN sed -i "s|;zend_extension=xdebug.so|zend_extension=xdebug.so|g" /usr/local/etc/php/conf.d/zz-xdebug-settings.ini
44
RUN sed -i "s|listen = 0.0.0.0:9001|listen = 0.0.0.0:9002|g" /usr/local/etc/php-fpm.conf
5+
RUN sed -i "s|xdebug.remote_connect_back = 1|xdebug.remote_host=192.168.99.1|g" /usr/local/etc/php-fpm.conf
56

6-
RUN apt-get update && apt-get install -y openssh-server
7-
RUN mkdir /var/run/sshd
8-
RUN echo 'root:123123q' | chpasswd
9-
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
10-
11-
# SSH login fix. Otherwise user is kicked off after login
12-
RUN sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
13-
14-
ENV NOTVISIBLE "in users profile"
15-
RUN echo "export VISIBLE=now" >> /etc/profile
16-
17-
EXPOSE 22
18-
CMD ["sh", "-c", "/usr/sbin/sshd -D && php-fpm -R"]
7+
CMD ["php-fpm", "-R"]

etc/helm/templates/cron.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
{{/*value: {{.Values.global.monolith.volumeHostPath}}/.composer*/}}
2828
{{/*- name: DEVBOX_ROOT_HOST*/}}
2929
{{/*value: {{.Values.global.monolith.volumeHostPath}}*/}}
30-
{{/*- name: IS_WINDOWS_HOST*/}}
31-
{{/*value: "0"*/}}
3230
{{/*volumes:*/}}
3331
{{/*- name: code*/}}
3432
{{/*{{- if .Values.global.persistence.nfs.enabled }}*/}}
@@ -68,8 +66,6 @@
6866
{{/*value: {{.Values.global.monolith.volumeHostPath}}/.composer*/}}
6967
{{/*- name: DEVBOX_ROOT_HOST*/}}
7068
{{/*value: {{.Values.global.monolith.volumeHostPath}}*/}}
71-
{{/*- name: IS_WINDOWS_HOST*/}}
72-
{{/*value: "0"*/}}
7369
{{/*volumes:*/}}
7470
{{/*- name: code*/}}
7571
{{/*{{- if .Values.global.persistence.nfs.enabled }}*/}}
@@ -110,8 +106,6 @@
110106
{{/*value: {{.Values.global.monolith.volumeHostPath}}/.composer*/}}
111107
{{/*- name: DEVBOX_ROOT_HOST*/}}
112108
{{/*value: {{.Values.global.monolith.volumeHostPath}}*/}}
113-
{{/*- name: IS_WINDOWS_HOST*/}}
114-
{{/*value: "0"*/}}
115109
{{/*volumes:*/}}
116110
{{/*- name: code*/}}
117111
{{/*{{- if .Values.global.persistence.nfs.enabled }}*/}}

etc/helm/templates/magento2-deployment.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ spec:
3131
securityContext:
3232
privileged: true
3333
ports:
34-
- containerPort: {{ .Values.global.monolith.service.port }}
34+
- containerPort: {{ .Values.global.monolith.service.phpFpmPort }}
3535
volumeMounts:
3636
- name: code
3737
mountPath: {{.Values.global.monolith.volumeHostPath}}
@@ -42,15 +42,30 @@ spec:
4242
value: {{.Values.global.monolith.volumeHostPath}}/.composer
4343
- name: DEVBOX_ROOT_HOST
4444
value: {{.Values.global.monolith.volumeHostPath}}
45-
- name: IS_WINDOWS_HOST
46-
value: "0"
4745
- name: {{ .Chart.Name }}-xdebug
4846
image: magento2-monolith:dev-xdebug
4947
imagePullPolicy: Never
5048
securityContext:
5149
privileged: true
5250
ports:
53-
- containerPort: {{ .Values.xdebugService.port }}
51+
- containerPort: {{ .Values.global.monolith.service.phpFpmXdebugPort }}
52+
{{/*- containerPort: 22*/}}
53+
volumeMounts:
54+
- name: code
55+
mountPath: {{.Values.global.monolith.volumeHostPath}}
56+
env:
57+
- name: DEVBOX_ROOT
58+
value: {{.Values.global.monolith.volumeHostPath}}
59+
- name: COMPOSER_HOME
60+
value: {{.Values.global.monolith.volumeHostPath}}/.composer
61+
- name: DEVBOX_ROOT_HOST
62+
value: {{.Values.global.monolith.volumeHostPath}}
63+
- name: {{ .Chart.Name }}-xdebug-cli-over-ssh
64+
image: magento2-monolith:dev-xdebug-and-ssh
65+
imagePullPolicy: Never
66+
securityContext:
67+
privileged: true
68+
ports:
5469
- containerPort: 22
5570
volumeMounts:
5671
- name: code
@@ -62,8 +77,6 @@ spec:
6277
value: {{.Values.global.monolith.volumeHostPath}}/.composer
6378
- name: DEVBOX_ROOT_HOST
6479
value: {{.Values.global.monolith.volumeHostPath}}
65-
- name: IS_WINDOWS_HOST
66-
value: "0"
6780
- name: nginx
6881
image: nginx:1.9
6982
securityContext:

scripts/guest/m-reinstall

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ source "${devbox_dir}/scripts/functions.sh"
77
get_config_value="${devbox_dir}/scripts/get_config_value.sh"
88
magento_host_name="$(bash ${get_config_value} "magento_host_name")"
99
use_nfs="$(bash "${devbox_dir}/scripts/get_env_config_value.sh" "guest_use_nfs")"
10-
is_windows_host=${IS_WINDOWS_HOST}
1110
generate_basic_data="$(bash ${get_config_value} "magento_generate_basic_data")"
1211

1312

@@ -40,10 +39,6 @@ setupOptions[amqp_user]='admin'
4039
setupOptions[amqp_password]='123123q'
4140
setupOptions[amqp_virtualhost]='/'
4241

43-
#if [[ ${is_windows_host} == 1 ]] || [[ ${use_nfs} == 0 ]]; then
44-
# sudo chown -R devbox:devbox ${DEVBOX_ROOT}/$(getContext)
45-
#fi
46-
#
4742
#status "Killing MQ processes"
4843
#pkill -f queue
4944

@@ -121,12 +116,6 @@ fi
121116

122117
bash "${devbox_dir}/scripts/guest/configure_varnish" -f
123118

124-
# TODO: Remove
125-
#if [[ ${is_windows_host} == 1 ]] || [[ ${use_nfs} == 0 ]]; then
126-
# status "Changing ownership of "${DEVBOX_ROOT}/$(getContext)" to devbox:devbox"
127-
# sudo chown -R devbox:devbox ${DEVBOX_ROOT}/$(getContext)
128-
#fi
129-
130119
bash "${DEVBOX_ROOT}/scripts/guest/configure_search_engine"
131120
bash "${DEVBOX_ROOT}/scripts/guest/change_magento_config_for_functional_tests"
132121
bash "${DEVBOX_ROOT}/scripts/guest/update_magento_config" 'admin/security/session_lifetime' '86400'

scripts/host/k_install_environment.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source "${devbox_dir}/scripts/functions.sh"
77
## TODO: Add status messages
88
cd "${devbox_dir}/scripts" && eval $(minikube docker-env) && docker build -t magento2-monolith:dev -f ../etc/docker/monolith/Dockerfile ../scripts
99
cd "${devbox_dir}/scripts" && eval $(minikube docker-env) && docker build -t magento2-monolith:dev-xdebug -f ../etc/docker/monolith-with-xdebug/Dockerfile ../scripts
10+
cd "${devbox_dir}/scripts" && eval $(minikube docker-env) && docker build -t magento2-monolith:dev-xdebug-and-ssh -f ../etc/docker/monolith-with-xdebug-and-ssh/Dockerfile ../scripts
1011

1112
# TODO: Repeat for other deployments, not just Magento 2
1213
# See https://github.com/kubernetes/kubernetes/issues/33664#issuecomment-386661882

scripts/host/k_upgrade_environment.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source "${devbox_dir}/scripts/functions.sh"
77
## TODO: Add status messages
88
cd "${devbox_dir}/scripts" && eval $(minikube docker-env) && docker build -t magento2-monolith:dev -f ../etc/docker/monolith/Dockerfile ../scripts
99
cd "${devbox_dir}/scripts" && eval $(minikube docker-env) && docker build -t magento2-monolith:dev-xdebug -f ../etc/docker/monolith-with-xdebug/Dockerfile ../scripts
10+
cd "${devbox_dir}/scripts" && eval $(minikube docker-env) && docker build -t magento2-monolith:dev-xdebug-and-ssh -f ../etc/docker/monolith-with-xdebug-and-ssh/Dockerfile ../scripts
1011

1112
# TODO: Repeat for other deployments, not just Magento 2
1213
# See https://github.com/kubernetes/kubernetes/issues/33664#issuecomment-386661882

tests/include/assertions.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function executeExtendedCommonAssertions()
3939
assertElasticSearchEnabled
4040
assertElasticSearchDisablingWorks
4141
assertElasticSearchEnablingWorks
42+
43+
assertXdebugContainerWorks
4244
}
4345

4446
## Assertions
@@ -542,3 +544,15 @@ function assertRemotePhpWorks()
542544

543545
assertTrue "Remote PHP is not accessible ('php -i' failed to execute over ssh)." '[[ ${remote_php_ini_contents} =~ "PHP License" ]]'
544546
}
547+
548+
function assertXdebugContainerWorks()
549+
{
550+
echo "${blue}## assertXdebugContainerWorks${regular}"
551+
echo "## assertXdebugContainerWorks" >>${current_log_file_path}
552+
553+
cd ${tests_dir}
554+
magento_page_content="$(curl -sL --cookie "XDEBUG_SESSION=PHPSTORM" "${current_magento_base_url}/customer/account/create/")"
555+
pattern="Magento.* All rights reserved."
556+
assertTrue "Account creation page is not accessible when queried with XDEBUG_SESSION cookie. URL: '${current_magento_base_url}/customer/account/create/'" '[[ ${magento_page_content} =~ ${pattern} ]]'
557+
558+
}

0 commit comments

Comments
 (0)