Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SC-1728: Glue End2End tests are failing #13

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Ignore generated files
deployment/*
!deployment/.gitkeep

.idea/
generator/vendor
17 changes: 7 additions & 10 deletions generator/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$mountMode = $projectData['_mountMode'] = retrieveMountMode($projectData, $platform);
$projectData['_ports'] = retrieveUniquePorts($projectData);
$defaultPort = $projectData['_defaultPort'] = getDefaultPort($projectData);
$yvesEndpointMap = $projectData['_yvesEndpointMap'] = buildYvesEndpointMapByStore($projectData['groups']);
$endpointMap = $projectData['_endpointMap'] = buildEndpointMapByStore($projectData['groups']);

mkdir($deploymentDir . DS . 'env' . DS . 'cli', 0777, true);
mkdir($deploymentDir . DS . 'context' . DS . 'nginx' . DS . 'conf.d', 0777, true);
Expand Down Expand Up @@ -90,7 +90,7 @@
$projectData['regions'][$groupData['region']]['stores'][$endpointData['store']]['services'],
$endpointData['services'] ?? []
),
'yvesEndpointMap' => $yvesEndpointMap,
'endpointMap' => $endpointMap,
])
);
}
Expand All @@ -117,6 +117,7 @@
$projectData['regions'][$groupData['region']]['stores'][$endpointData['store']]['services'],
$endpointData['services'] ?? []
),
'endpointMap' => $endpointMap,
])
);
}
Expand Down Expand Up @@ -330,26 +331,22 @@ function getBrokerConnections(array $projectData): string
*
* @return string[]
*/
function buildYvesEndpointMapByStore(array $projectGroups): array
function buildEndpointMapByStore(array $projectGroups): array
{
$yvesEndpointMap = [];
$endpointMap = [];

foreach ($projectGroups as $projectGroup) {
$applicationsPerRegion = $projectGroup['applications'];

foreach ($applicationsPerRegion as $application) {
$applicationName = $application['application'];

if ($applicationName !== 'yves') {
continue;
}

foreach ($application['endpoints'] as $endpoint => $endpointData) {
$storeName = $endpointData['store'];
$yvesEndpointMap[$storeName] = $endpoint;
$endpointMap[$storeName][$applicationName] = $endpoint;
}
}
}

return $yvesEndpointMap;
return $endpointMap;
}
39 changes: 34 additions & 5 deletions generator/src/templates/deploy.bash.twig
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function showHelp()
echo -e " ${GREEN}console${NC}\t - Run Spryker console command, e.g. \`${ITALIC}${SPRYKER_SELF_SCRIPT} console code:test -vvv -g Acceptance\`${NC}."
echo -e " ${GREEN}codecept${NC}\t - Start a new container where you can run Codeception commands in the test environment."
echo -e " ${GREEN}code-checks${NC}\t - Run code-checks."
echo -e " ${GREEN}api-tests${NC} - Run api-tests, e.g. \`${ITALIC}${SPRYKER_SELF_SCRIPT} api-tests -v -g Product\`${NC} or \`${ITALIC}${SPRYKER_SELF_SCRIPT} api-tests -h\`${NC}."
echo -e " ${GREEN}acceptance-tests${NC} - Run acceptance-tests, e.g. \`${ITALIC}${SPRYKER_SELF_SCRIPT} acceptance-tests -v -g Acceptance\`${NC} or \`${ITALIC}${SPRYKER_SELF_SCRIPT} acceptance-tests -h\`${NC}."
echo -e " ${GREEN}functional-tests${NC} - Run functional-tests, e.g. \`${ITALIC}${SPRYKER_SELF_SCRIPT} functional-tests -v\`${NC} or \`${ITALIC}${SPRYKER_SELF_SCRIPT} functional-tests -h\`${NC}."
echo -e " ${GREEN}demo|demo-data${NC} - Populate Spryker demo data."
Expand Down Expand Up @@ -466,6 +467,27 @@ function execSpryker()
${SPRYKER_DOCKER_PREFIX}_cli:${SPRYKER_DOCKER_TAG} /usr/local/bin/execute.sh
}

function execCodecept()
{
waitFor database
waitFor broker
waitFor search
waitFor key_value_store
waitFor session

local tty
[ -t -0 ] && tty='' || tty='-T'

local binary=/usr/local/bin/execute.sh
[ -z "${*}" ] && binary=bash

execDockerCompose exec \
-e COMMAND="${*}" \
-e PS1="spryker@codecept\$" \
codecept \
${binary}
}

function execSprykerMultiString()
{
setExtraEnvFiles
Expand Down Expand Up @@ -501,7 +523,7 @@ function execDockerCompose()
--project-directory ${PROJECT_DIR} \
--project-name ${SPRYKER_DOCKER_PREFIX} \
${DOCKER_COMPOSE_FILES} \
$@
"$@"
}

function doUp()
Expand Down Expand Up @@ -554,6 +576,8 @@ function doPull()
}

case $1 in
api-tests)
;;
acceptance-tests)
;;
functional-tests)
Expand Down Expand Up @@ -703,16 +727,21 @@ case $1 in
;;
codecept)
ensureTestingMode
PS1="spryker-codecept@\u\$ " # TODO what is it?
doCli $2 ${@:3}
execCodecept "${@:2}"
;;
functional-tests)
ensureTestingMode
doCli console code:test:functional ${@:2}
execCodecept console code:test:functional "${@:2}"
;;
acceptance-tests)
ensureTestingMode
doCli console code:test:acceptance ${@:2}
execCodecept console code:test:acceptance "${@:2}"
;;
api-tests)
ensureTestingMode
execCodecept console code:fixtures "${@:2}"
execCodecept console queue:worker:start
execCodecept console code:test:api "${@:2}"
;;
logs)
execSpryker "find ${SPRYKER_LOG_DIRECTORY} -type f \( -name \"exception.log\" \) -exec tail -f \"$file\" {} +"
Expand Down
59 changes: 51 additions & 8 deletions generator/src/templates/docker-compose.test.yml.twig
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
version: "3.5"

x-volumes:
&app-volumes
volumes:
- logs:${SPRYKER_LOG_DIRECTORY}:rw
- ./${DEPLOYMENT_PATH}/context/php/php-fpm.d/worker.conf:/usr/local/etc/php-fpm.d/worker.conf:ro
- ./${DEPLOYMENT_PATH}/context/php/php.ini:/usr/local/etc/php.ini:ro
{% if _mountMode != 'baked' %}
- ./${DEPLOYMENT_PATH}/context/php/conf.d/opcache_dev.ini:/usr/local/etc/php/conf.d/opcache.ini:ro
{% if _mountMode == 'native' %}
- ./:/data
{% else %}
- ${SPRYKER_DOCKER_PREFIX}_${SPRYKER_DOCKER_TAG}_data_sync:/data
{% endif %}
{% endif %}

x-env_file:
&test-envfile
env_file:
- ${DEPLOYMENT_PATH}/env/testing.env

x-links:
&test-links
links:
{% for group in groups %}
{% for applicationName, applicationData in group['applications'] %}
{% for endpoint, endpointData in applicationData['endpoints'] %}
- frontend:{{ endpoint | split(':') | first }}
{% endfor %}
{% endfor %}
{% endfor %}

services:
{% for group in groups %}
{% for applicationName, applicationData in group['applications'] %}
Expand All @@ -23,16 +49,33 @@ services:
ports:
- 4444:4444
command: "phantomjs --webdriver=4444 --disk-cache=true --load-images=false --webdriver-loglevel=DEBUG"
links:
{% for group in groups %}
{% for applicationName, applicationData in group['applications'] %}
{% for endpoint, endpointData in applicationData['endpoints'] %}
- frontend:{{ endpoint | split(':') | first }}
{% endfor %}
{% endfor %}
{% endfor %}
<<: *test-links

codecept:
image: ${SPRYKER_DOCKER_PREFIX}_cli:${SPRYKER_DOCKER_TAG}
networks:
- services
- public
- private
depends_on:
- database
- broker
- key_value_store
- session
- search
env_file:
- ${DEPLOYMENT_PATH}/env/cli/{{ docker['testing']['store'] | lower }}.env
- ${DEPLOYMENT_PATH}/env/cli/testing.env
<<: *app-volumes
<<: *test-links
tty: true
command:
- "nc"
- "-l"
- "9000"

scheduler:
image: nginx:alpine
user: "0:0"
volumes:
- ./${DEPLOYMENT_PATH}/context/nginx/dummy/scheduler.conf:/etc/nginx/conf.d/default.conf:ro
8 changes: 5 additions & 3 deletions generator/src/templates/env/cli/store.env.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ SPRYKER_KEY_VALUE_STORE_NAMESPACE={{ services['key_value_store']['namespace'] }}
SPRYKER_BROKER_NAMESPACE={{ services['broker']['namespace'] }}
SPRYKER_SESSION_BE_NAMESPACE={{ services['session']['namespace'] }}

{% if yvesEndpointMap[storeName] is not empty %}
SPRYKER_FE_HOST={{ yvesEndpointMap[storeName] | split(':') | first }}
SPRYKER_FE_PORT={{ (yvesEndpointMap[storeName] | split(':'))[1] | default(80) }}
{% if endpointMap[storeName] is not empty %}
SPRYKER_FE_HOST={{ endpointMap[storeName]['yves'] | split(':') | first }}
SPRYKER_FE_PORT={{ (endpointMap[storeName]['yves'] | split(':'))[1] | default(80) }}
SPRYKER_API_HOST={{ endpointMap[storeName]['glue'] | split(':') | first }}
SPRYKER_API_PORT={{ (endpointMap[storeName]['glue'] | split(':'))[1] | default(80) }}
{% endif %}
11 changes: 8 additions & 3 deletions generator/src/templates/nginx/http/rpc.server.conf.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
fastcgi_param SPRYKER_BE_HOST {{ host }};
fastcgi_param SPRYKER_BE_PORT {{ port }};

{% if project['_yvesEndpointMap'][endpointData['store']] is not empty %}
fastcgi_param SPRYKER_FE_HOST {{ project['_yvesEndpointMap'][endpointData['store']] }};
fastcgi_param SPRYKER_FE_PORT {{ (project['_yvesEndpointMap'][endpointData['store']] | split(':'))[1] | default(80) }};
{% if project['_endpointMap'][endpointData['store']]['yves'] is not empty %}
fastcgi_param SPRYKER_FE_HOST {{ project['_endpointMap'][endpointData['store']]['yves'] }};
fastcgi_param SPRYKER_FE_PORT {{ (project['_endpointMap'][endpointData['store']]['yves'] | split(':'))[1] | default(80) }};
{% endif %}

{% if project['_endpointMap'][endpointData['store']]['glue'] is not empty %}
fastcgi_param SPRYKER_API_HOST {{ project['_endpointMap'][endpointData['store']]['glue'] }};
fastcgi_param SPRYKER_API_PORT {{ (project['_endpointMap'][endpointData['store']]['glue'] | split(':'))[1] | default(80) }};
{% endif %}

root /data/public/Zed;
Expand Down