Comments

jigish.addweb created an issue. See original summary.

jigish.addweb’s picture

StatusFileSize
new90.93 KB
jigish.addweb’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 3135925-2.patch, failed testing. View results

yas’s picture

@jigishaddweb

Thank you for adding the test case.

  1. Could you please fix the test cases such as OpenStackVolumeAttachDetachTest and OpenStackInstanceExtraTest? See also at https://www.drupal.org/pift-ci-job/1684133. The other test case errors already existed, so please focus on two test case errors in this patch.
  2. The following code should be placed into OpenStackCloudTestEntityTrait so that we don't have to add $is_openstack = FALSE which is the OpenStack-specific code. I like the approach to re-use the existing code and not introducing the similar method, however in this case I don't feel we should mix the logic for both AWS an OpenStack at createServerTemplateTestEntity.
    +++ b/modules/cloud_service_providers/aws_cloud/tests/src/Traits/AwsCloudTestEntityTrait.php
    @@ -393,21 +392,27 @@ trait AwsCloudTestEntityTrait {
    
       protected function createServerTemplateTestEntity(array $iam_roles,
    -                                                    Image $image,
    -                                                    $cloud_context): CloudContentEntityBase {
    +                                                    $image,
    +                                                    $cloud_context,
    +                                                    $is_openstack = FALSE): CloudContentEntityBase {
    
  3. I think this one also should be placed into OpenStackTestFormDataTrait.
    +++ b/modules/cloud_service_providers/aws_cloud/tests/src/Traits/AwsCloudTestFormDataTrait.php
    @@ -164,11 +164,13 @@ trait AwsCloudTestFormDataTrait {
    
    -  protected function createInstanceTestFormData($repeat_count = 1): array {
    +  protected function createInstanceTestFormData($repeat_count = 1, $is_openstack = FALSE): array {
    
  4. Could you please explain why the following permission needed to be changed?
    +++ b/modules/cloud_service_providers/openstack/config/install/views.view.openstack_instance.yml
    @@ -23,7 +23,7 @@ display:
           access:
             type: perm
             options:
    -          perm: 'edit openstack instances'
    +          perm: 'list openstack images'
    
  5. I wonder if the specified class name OpenStackInstanceTest::class is correct or not. (Not OpenStackInstance::class?)
    +++ b/modules/cloud_service_providers/openstack/tests/src/Functional/OpenStack/OpenStackVolumeAttachDetachTest.php
    @@ -149,7 +149,7 @@ class OpenStackVolumeAttachDetachTest extends OpenStackTestBase {
             // Setup a test instance.
             $instance = $this->createInstanceTestEntity(OpenStackInstance::class, $j, $regions);
             $instance_id = $instance->getInstanceId();
    -        $this->addInstanceMockData($instance->getName(), $instance->getKeyPairName());
    +        $this->addInstanceMockData(OpenStackInstanceTest::class, $instance->getName(), $instance->getKeyPairName(), $regions);
    
jigish.addweb’s picture

StatusFileSize
new90.35 KB
new9.42 KB
jigish.addweb’s picture

Status: Needs work » Needs review

@yas

Thank you for your review.

1. Fixed OpenStackVolumeAttachDetachTest and OpenStackInstanceExtraTest testcase errors.
2. Refactored code of createServerTemplateTestEntity.
3. Refactored code of createInstanceTestFormData.
4. Sorry, there was a mistake. Need to change it to list openstack instances for OpenStack Instance list as edit openstack instances permission gives an access denied in testcase.
5. yes, OpenStackInstanceTest::class is correct. getMockDataFileContent function read mock data of respective testcase. For example, If we add OpenStackInstanceTest::class, that will be getting mock data from OpenStackInstanceTest.yml file. InstanceTest::class is added in addInstanceMockData of AwsCloudTestMockTrait. I have refactored that code as below

@@ -141,7 +143,7 @@ trait AwsCloudTestMockTrait {
 
     $vars = array_merge($this->getMockDataTemplateVars(), $vars);
 
-    $instance_mock_data_content = $this->getMockDataFileContent(InstanceTest::class, $vars, '_instance');
+   $instance_mock_data_content = $this->getMockDataFileContent($class, $vars, '_instance');

Please review the updated patch.

Thanks

yas’s picture

Status: Needs review » Needs work

@jigishaddweb

Thank you for fixes. For 5., in that case, could you please add more information for the parameter? It should be:

FROM:

+++ b/modules/cloud_service_providers/aws_cloud/tests/src/Traits/AwsCloudTestMockTrait.php

@@ -93,10 +92,14 @@ trait AwsCloudTestMockTrait {
   /**
    * Add instance mock data.
    *
+   * @param string $class
+   *   The Instance class.
+++ b/modules/cloud_service_providers/aws_cloud/tests/src/Traits/AwsCloudTestMockTrait.php

@@ -263,16 +265,20 @@ trait AwsCloudTestMockTrait {
   /**
    * Update instance in mock data.
    *
+   * @param string $class
+   *   The Instance class.

TO: (for both above)

  * @param string $test_class
  *   The InstanceTest class.  It can be InstanceTest::class or
  *   OpenStackInstanceTest::class.
jigish.addweb’s picture

StatusFileSize
new90.89 KB
new3.72 KB
jigish.addweb’s picture

Status: Needs work » Needs review

@yas

I changed the parameter information as you suggested.

Please review the updated patch.

Thanks

yas’s picture

Status: Needs review » Reviewed & tested by the community

@jigishaddweb

Thank you for the update. It looks good to me now. Thank you for the refactoring. It looks good to me. I'll merge the patch to 8.x-1.x and 8.x-2.x and close this issue as Fixed.

  • yas committed 5ae7906 on 8.x-1.x authored by jigish.addweb
    Issue #3135925 by jigish.addweb, yas: Add test cases for OpenStack...

  • yas committed 4bbde94 on 8.x-2.x authored by jigish.addweb
    Issue #3135925 by jigish.addweb, yas: Add test cases for OpenStack...
yas’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.