[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15176545#comment-15176545
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9298:
--------------------------------------------

Github user pedro-martins commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1425#discussion_r54797480
  
    --- Diff: server/test/com/cloud/api/query/dao/TemplateJoinDaoImplTest.java 
---
    @@ -0,0 +1,56 @@
    +package com.cloud.api.query.dao;
    +
    +import junit.framework.TestCase;
    +
    +import org.apache.cloudstack.api.response.ResourceTagResponse;
    +import org.apache.cloudstack.api.response.TemplateResponse;
    +import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.mockito.InjectMocks;
    +import org.mockito.Mock;
    +import org.mockito.MockitoAnnotations;
    +import org.powermock.api.mockito.PowerMockito;
    +import org.powermock.core.classloader.annotations.PrepareForTest;
    +import org.powermock.modules.junit4.PowerMockRunner;
    +
    +import com.cloud.api.ApiDBUtils;
    +import com.cloud.api.query.vo.TemplateJoinVO;
    +import com.cloud.user.AccountService;
    +
    +@RunWith(PowerMockRunner.class)
    +@PrepareForTest(ApiDBUtils.class)
    +public class TemplateJoinDaoImplTest extends TestCase {
    +
    +    @Mock(name="_configDao")
    +    private ConfigurationDao _configDao;
    +
    +    @Mock(name="_accountService")
    +    private AccountService _accountService;
    +
    +    @InjectMocks
    +    private TemplateJoinDaoImpl _templateJoinDaoImpl;
    +
    +    private TemplateJoinVO template = new TemplateJoinVO();
    +    private TemplateResponse templateResponse = new TemplateResponse();
    +
    +    private final static long TAG_ID = 1l;
    +    private final static String TAG_UUID = "aaaa-aaaa-aaaa-aaaa";
    +
    +    @Before
    +    public void setup() {
    +        MockitoAnnotations.initMocks(this);
    +        template.setTagId(TAG_ID);
    +        template.setTagUuid(TAG_UUID);
    +        PowerMockito.spy(ApiDBUtils.class);
    +        PowerMockito.stub(PowerMockito.method(ApiDBUtils.class, 
"newResourceTagResponse")).toReturn(new ResourceTagResponse());
    +    }
    +
    +    @Test
    +    public void testUpdateTemplateTagInfo(){
    +        assertEquals(0, templateResponse.getTags().size());
    +        _templateJoinDaoImpl.updateTemplateTagInformation(template, 
templateResponse);
    +        assertEquals(1, templateResponse.getTags().size());
    +    }
    --- End diff --
    
    Hi, @nvazquez.
    
    I see a little mistake in you test, you are testing if the method has 
inserted a tag or not, I think that this test needs to verify if the template 
inserted in the templateResponse is the same that you has passed in the first 
param of the method.
    You can do it checking if each variable in both templates are equals.
    
    The same problem in the other tests cases.
    
    Ty.


> Improve performance of resource retrieval that have tags associated and 
> target volumes, VMs and templates
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-9298
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9298
>             Project: CloudStack
>          Issue Type: Improvement
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: API
>    Affects Versions: 4.9.0
>            Reporter: Nicolas Vazquez
>             Fix For: 4.9.0
>
>
> h2. Description of the problem
> When retrieving a large number of resources which have tags associated with, 
> retrieval methods took too long. Our goal is to improve performance of this 
> methods
> h3. ListTemplatesCmd API method
> It is proposed to include tags information into template_view to avoid 
> querying the database for each tag, managing that information in memory.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to