@@ -531,51 +531,28 @@ public function testAhoyWorkflowProvisionFallbackToProfile(): void {
531531 $ this ->cmd ('ahoy drush pm:list --status=enabled --type=module --format=list ' , '* shield ' , 'Shield module should be enabled after fallback provision ' );
532532
533533 // Diagnostic probes to understand why the homepage hits the redirect
534- // module after a fallback profile install. Each command is routed through
535- // 'ahoy cli' with a single-quoted outer arg so multi-word args (queries,
536- // eval expressions) survive ahoy's '$*' expansion intact.
534+ // module after a fallback profile install. Each probe writes its full
535+ // output to '.logs/debug-<name>.txt' so it ships out as a test artifact
536+ // (cmd()'s streaming output is suppressed in CI). Multi-word args route
537+ // through 'ahoy cli' with a single-quoted outer arg so they survive
538+ // ahoy's '$*' expansion intact.
537539 // @todo Remove once the underlying cause is understood and fixed.
538- $ this ->logSubstep ('DEBUG: enabled modules per core.extension ' );
539- $ this ->cmd ("ahoy cli 'vendor/bin/drush pm:list --status=enabled --type=module --format=list' " );
540-
541- $ this ->logSubstep ('DEBUG: core.extension config dump ' );
542- $ this ->cmd ("ahoy cli 'vendor/bin/drush config:get core.extension' " );
543-
544- $ this ->logSubstep ('DEBUG: redirect module status (should be disabled after fallback) ' );
545- $ this ->cmd ("ahoy cli 'vendor/bin/drush pm:list --filter=redirect --format=list || true' " );
546-
547- $ this ->logSubstep ('DEBUG: all DB tables ' );
548- $ this ->cmd ("ahoy cli 'vendor/bin/drush sql:query \"SHOW TABLES \"' " );
549-
550- $ this ->logSubstep ('DEBUG: redirect-related DB tables (should be empty) ' );
551- $ this ->cmd ("ahoy cli 'vendor/bin/drush sql:query \"SHOW TABLES LIKE \\\"redirect% \\\"\" || true' " );
552-
553- $ this ->logSubstep ('DEBUG: cache_container row count ' );
554- $ this ->cmd ("ahoy cli 'vendor/bin/drush sql:query \"SELECT COUNT(*) FROM cache_container \" || true' " );
555-
556- $ this ->logSubstep ('DEBUG: PhpStorage layout under web/sites/default/files/php ' );
557- $ this ->cmd ("ahoy cli 'ls -la web/sites/default/files/php/ 2>/dev/null || echo NO_PHP_DIR' " );
558- $ this ->cmd ("ahoy cli 'ls -la web/sites/default/files/php/container/ 2>/dev/null || echo NO_CONTAINER_DIR' " );
559- $ this ->cmd ("ahoy cli 'find web/sites/default/files/php -type f 2>/dev/null | head -30 || echo NO_FILES' " );
560-
561- $ this ->logSubstep ('DEBUG: presence of redirect references in cached container files ' );
562- $ this ->cmd ("ahoy cli 'grep -l \"Drupal..redirect \" web/sites/default/files/php/container/*.php 2>/dev/null || echo NO_REDIRECT_IN_CONTAINER_CACHE' " );
563- $ this ->cmd ("ahoy cli 'grep -c \"redirect.request_subscriber \\|RedirectRequestSubscriber \" web/sites/default/files/php/container/*.php 2>/dev/null || echo NO_REDIRECT_SUBSCRIBER_IN_CACHE' " );
564-
565- $ this ->logSubstep ('DEBUG: hash_salt and deployment_identifier ' );
566- $ this ->cmd ("ahoy cli 'vendor/bin/drush php:eval \"echo \\\"hash_salt= \\\" . substr( \\\\Drupal \\\\Core \\\\Site \\\\Settings::get( \\\"hash_salt \\\"), 0, 12) . PHP_EOL; echo \\\"deployment_identifier= \\\" . ( \\\\Drupal \\\\Core \\\\Site \\\\Settings::get( \\\"deployment_identifier \\\") ?? \\\"(null) \\\") . PHP_EOL; \"' " );
567-
568- $ this ->logSubstep ('DEBUG: runtime active modules per Drupal kernel ' );
569- $ this ->cmd ("ahoy cli 'vendor/bin/drush php:eval \"foreach (array_keys( \\\\Drupal::moduleHandler()->getModuleList()) as \\\$m) { echo \\\$m . PHP_EOL; } \"' " );
570-
571- $ this ->logSubstep ('DEBUG: redirect/path_processor service ids in live container ' );
572- $ this ->cmd ("ahoy cli 'vendor/bin/drush php:eval \"foreach ( \\\\Drupal::getContainer()->getServiceIds() as \\\$id) { if (str_contains( \\\$id, \\\"path_processor \\\") || str_contains( \\\$id, \\\"redirect \\\")) { echo \\\$id . PHP_EOL; } } \"' " );
573-
574- $ this ->logSubstep ('DEBUG: last 30 watchdog entries ' );
575- $ this ->cmd ("ahoy cli 'vendor/bin/drush watchdog:show --count=30 || true' " );
576-
577- $ this ->logSubstep ('DEBUG: head of homepage response ' );
578- $ this ->cmd ("ahoy cli 'curl -sS -o - -w \"\\nHTTP_STATUS=%{http_code} \\n \" http://nginx:8080/ | head -c 4000' " );
540+ $ logs_dir = self ::locationsRoot () . '/.vortex/tests/.logs ' ;
541+ @mkdir ($ logs_dir , 0777 , TRUE );
542+
543+ $ this ->captureProbe ($ logs_dir , '01-enabled-modules.txt ' , "ahoy cli 'vendor/bin/drush pm:list --status=enabled --type=module --format=list' " );
544+ $ this ->captureProbe ($ logs_dir , '02-core-extension.txt ' , "ahoy cli 'vendor/bin/drush config:get core.extension' " );
545+ $ this ->captureProbe ($ logs_dir , '03-redirect-module-status.txt ' , "ahoy cli 'vendor/bin/drush pm:list --filter=redirect --format=list || true' " );
546+ $ this ->captureProbe ($ logs_dir , '04-show-tables.txt ' , "ahoy cli 'vendor/bin/drush sql:query \"SHOW TABLES \" || true' " );
547+ $ this ->captureProbe ($ logs_dir , '05-redirect-tables.txt ' , "ahoy cli 'vendor/bin/drush sql:query \"SHOW TABLES LIKE \\\"redirect% \\\"\" || true' " );
548+ $ this ->captureProbe ($ logs_dir , '06-cache-container-count.txt ' , "ahoy cli 'vendor/bin/drush sql:query \"SELECT COUNT(*) FROM cache_container \" || true' " );
549+ $ this ->captureProbe ($ logs_dir , '07-phpstorage-ls-php.txt ' , "ahoy cli 'ls -la web/sites/default/files/php/ 2>/dev/null || echo NO_PHP_DIR' " );
550+ $ this ->captureProbe ($ logs_dir , '08-phpstorage-ls-container.txt ' , "ahoy cli 'ls -la web/sites/default/files/php/container/ 2>/dev/null || echo NO_CONTAINER_DIR' " );
551+ $ this ->captureProbe ($ logs_dir , '09-phpstorage-find.txt ' , "ahoy cli 'find web/sites/default/files/php -type f 2>/dev/null | head -50 || echo NO_FILES' " );
552+ $ this ->captureProbe ($ logs_dir , '10-grep-redirect-in-cache.txt ' , "ahoy cli 'grep -l Drupal..redirect web/sites/default/files/php/container/*.php 2>/dev/null || echo NO_REDIRECT_IN_CONTAINER_CACHE' " );
553+ $ this ->captureProbe ($ logs_dir , '11-grep-subscriber-in-cache.txt ' , "ahoy cli 'grep -c redirect.request_subscriber web/sites/default/files/php/container/*.php 2>/dev/null || echo NO_REDIRECT_SUBSCRIBER_IN_CACHE' " );
554+ $ this ->captureProbe ($ logs_dir , '12-watchdog.txt ' , "ahoy cli 'vendor/bin/drush watchdog:show --count=30 || true' " );
555+ $ this ->captureProbe ($ logs_dir , '13-homepage.txt ' , "ahoy cli 'curl -sS -o /tmp/homepage.html -w HTTP_STATUS=%{http_code} http://nginx:8080/ ; echo ; head -c 4000 /tmp/homepage.html' " );
579556
580557 $ this ->logSubstep ('Assert that homepage does not contain database dump content ' );
581558 $ this ->assertWebpageNotContains ('/ ' , 'This demo page is sourced from the Vortex database dump file ' , 'Homepage should not show database dump content after fallback provision ' );
@@ -584,4 +561,40 @@ public function testAhoyWorkflowProvisionFallbackToProfile(): void {
584561 $ this ->assertWebpageContains ('/ ' , '<html ' , 'Homepage should be a valid HTML page ' );
585562 }
586563
564+ /**
565+ * Run a diagnostic probe and dump its full output to a log artifact file.
566+ *
567+ * Probes are non-fatal: any process error is captured to the file along with
568+ * stdout/stderr so the test continues to the next probe and finally the
569+ * homepage assertion. Output ships out via the test-artifacts upload of
570+ * '.vortex/tests/.logs'.
571+ *
572+ * @todo Remove with the diagnostic block in
573+ * testAhoyWorkflowProvisionFallbackToProfile() once the underlying cause
574+ * is understood and fixed.
575+ */
576+ protected function captureProbe (string $ logs_dir , string $ filename , string $ command ): void {
577+ $ this ->logSubstep ('DEBUG probe -> ' . $ filename );
578+
579+ try {
580+ $ process = $ this ->processRun ($ command );
581+ $ payload = sprintf (
582+ "COMMAND: \n %s \n\nEXIT CODE: %d \n\n--- STDOUT --- \n%s \n--- STDERR --- \n%s \n" ,
583+ $ command ,
584+ $ process ->getExitCode () ?? -1 ,
585+ $ process ->getOutput (),
586+ $ process ->getErrorOutput ()
587+ );
588+ }
589+ catch (\Throwable $ exception ) {
590+ $ payload = sprintf (
591+ "COMMAND: \n %s \n\nEXCEPTION: %s \n" ,
592+ $ command ,
593+ $ exception ->getMessage ()
594+ );
595+ }
596+
597+ file_put_contents ($ logs_dir . '/debug- ' . $ filename , $ payload );
598+ }
599+
587600}
0 commit comments