google-cloud-php
google-cloud-php copied to clipboard
Cannot set up Compute system tests
Environment details
- OS: gLinux
- PHP version: 7.4.15
- Package name and version: GCE client
Steps to reproduce
-
git clone https://github.com/georgiyekkert/google-cloud-php.git
- Export the keyfile constants, as well as the GOOGLE_CLOUD_PROJECT and PROJECT_ID env vars
-
cd Compute
-
composer install
- Run gcloud auth login
- Make the changes below in SmokeTest and PaginationTest
- Run the tests:
vendor/bin/phpunit -c phpunit-system.xml.dist tests/System/
- Observe the errors at the bottom.
Changes to PaginationTest
public static function setUpBeforeClass(): void
{
self::$projectId = getenv('PROJECT_ID');
$keyFilePath = getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH');
if (self::$projectId === false) {
self::fail('Environment variable PROJECT_ID must be set for smoke test');
}
if ($keyFilePath === false) {
self::fail('Environment variable GOOGLE_CLOUD_PHP_TESTS_KEY_PATH must be set for smoke test');
}
$options = ['credentials' => $keyFilePath];
self::$instancesClient = new InstancesClient($options);
self::$zonesClient = new ZonesClient($options);
}
Changes to SmokeTest
public static function setUpBeforeClass(): void
{
self::$projectId = getenv('PROJECT_ID');
$keyFilePath = getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH');
if (self::$projectId === false) {
self::fail('Environment variable PROJECT_ID must be set for smoke test');
}
if ($keyFilePath === false) {
self::fail('Environment variable GOOGLE_CLOUD_PHP_TESTS_KEY_PATH must be set for smoke test');
}
$options = ['credentials' => $keyFilePath];
self::$instancesClient = new InstancesClient($options);
self::$machineType = sprintf(
'https://www.googleapis.com/compute/v1/projects/%s/zones/%s/machineTypes/n1-standard-1',
self::$projectId,
self::ZONE
);
}
Hi @miraleung First of apologies for a late follow up on this, but I have a few questions on this.
The step 5 uses a gcloud auth login
but then your setUpBeforeClass
code uses GOOGLE_CLOUD_PHP_TESTS_KEY_PATH
.
Is the step 5 required because AFAIK client libraries use gcloud application-default login
.
Also, if possible could you specify what are the exact errors you are observing because I do see an error:
Call to a member function close() on null
but that refers to self::$acceleratorTypesClient
not being initialized in your setup function.
IIRC this might have originated from post-processing code that was needed on the raw Gapics generated from g3, and I think @dwsupplee might have ended running these tests successfully. @dwsupplee may have more context as well.
Closing this issue due to inactivity. Please reopen this issue if needed. Thank you!