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

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

Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1884#discussion_r95032496
  
    --- Diff: 
api/test/org/apache/cloudstack/api/command/test/ListCapabilitiesCmdTest.java ---
    @@ -0,0 +1,80 @@
    +// Licensed to the Apache Software Foundation (ASF) under one
    +// or more contributor license agreements.  See the NOTICE file
    +// distributed with this work for additional information
    +// regarding copyright ownership.  The ASF licenses this file
    +// to you under the Apache License, Version 2.0 (the
    +// "License"); you may not use this file except in compliance
    +// with the License.  You may obtain a copy of the License at
    +//
    +//   http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing,
    +// software distributed under the License is distributed on an
    +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +// KIND, either express or implied.  See the License for the
    +// specific language governing permissions and limitations
    +// under the License.
    +
    +package org.apache.cloudstack.api.command.test;
    +
    +
    +import com.cloud.server.ManagementService;
    +import com.cloud.utils.Pair;
    +import junit.framework.Assert;
    +import junit.framework.TestCase;
    +import org.apache.cloudstack.api.ResponseGenerator;
    +import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
    +import org.apache.cloudstack.api.command.user.config.ListCapabilitiesCmd;
    +import org.apache.cloudstack.api.response.CapabilitiesResponse;
    +import org.apache.cloudstack.api.response.ConfigurationResponse;
    +import org.apache.cloudstack.api.response.ListResponse;
    +import org.apache.cloudstack.config.Configuration;
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.mockito.Mockito;
    +
    +import java.util.ArrayList;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +
    +public class ListCapabilitiesCmdTest extends TestCase {
    +
    +    private ListCapabilitiesCmd listCapabilitiesCmd;
    +    private ManagementService mgr;
    +    private ResponseGenerator responseGenerator;
    +
    +    @Override
    +    @Before
    +    public void setUp() {
    +        responseGenerator = Mockito.mock(ResponseGenerator.class);
    +        mgr = Mockito.mock(ManagementService.class);
    +        listCapabilitiesCmd = new ListCapabilitiesCmd();
    +    }
    +
    +    @Test
    +    public void testCreateSuccess() {
    +
    +        listCapabilitiesCmd._mgr = mgr;
    +        listCapabilitiesCmd._responseGenerator = responseGenerator;
    +
    +        Map<String, Object> result = new HashMap<String, Object>();
    +
    +        try {
    +            
Mockito.when(mgr.listCapabilities(listCapabilitiesCmd)).thenReturn(result);
    +        } catch (Exception e) {
    +            Assert.fail("Received exception when success expected " + 
e.getMessage());
    +        }
    --- End diff --
    
    Why not perform lines 58-67 in in `setUp`?  Not only would this approach 
focus this method on the test operations, but remove the need for unnecessary 
class-level attributes.
    
    Also, catching exceptions is not required because JUnit will automatically 
fail when exceptions are thrown.  If there are checked exceptions, add them to 
the `throws` of the test method to keep test methods as succinct as possible.


> Metrics: Add a global setting to enable/disable Metrics view
> ------------------------------------------------------------
>
>                 Key: CLOUDSTACK-9699
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9699
>             Project: CloudStack
>          Issue Type: Improvement
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: UI
>    Affects Versions: 4.7.0, 4.8.0, 4.9.0
>            Reporter: Rashmi Dixit
>            Assignee: Rashmi Dixit
>             Fix For: 4.10.0.0
>
>         Attachments: enable-metrics-flag.PNG, metrics-disabled.PNG, 
> metrics-enabled.PNG
>
>
> The Metrics view for each type of entity basically fires APIs and calculates 
> required values on the client end. For e.g. to display memory usage etc at 
> the zone level, it will fetch all zones. For each zone it will fetch 
> pods->cluster->host->VMs
> For a very large Cloudstack installation this will have a major impact on the 
> performance. 
> Ideally, there should be an API which calculates all this in the backend and 
> the UI should simply show the values. However, for the time, introduce a 
> global setting called enable.metrics which will be set to false. This will 
> cause the metrics button not to be shown on any of the pages.
> If the Admin changes this to true, then the button will be visible and 
> Metrics functionality will work as usual.



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

Reply via email to