Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 69E28200BA1 for ; Mon, 17 Oct 2016 16:02:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 689CE160AFC; Mon, 17 Oct 2016 14:02:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AF35B160AE5 for ; Mon, 17 Oct 2016 16:01:59 +0200 (CEST) Received: (qmail 8615 invoked by uid 500); 17 Oct 2016 14:01:58 -0000 Mailing-List: contact issues-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list issues@cloudstack.apache.org Received: (qmail 8596 invoked by uid 500); 17 Oct 2016 14:01:58 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 8586 invoked by uid 99); 17 Oct 2016 14:01:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2016 14:01:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id B1C1F2C4C73 for ; Mon, 17 Oct 2016 14:01:58 +0000 (UTC) Date: Mon, 17 Oct 2016 14:01:58 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-9280) System VM volumes cannot be deleted when there are no system VMs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 17 Oct 2016 14:02:00 -0000 [ https://issues.apache.org/jira/browse/CLOUDSTACK-9280?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15582346#comment-15582346 ] ASF GitHub Bot commented on CLOUDSTACK-9280: -------------------------------------------- Github user GabrielBrascher commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1559#discussion_r83600411 --- Diff: engine/storage/test/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelectorTest.java --- @@ -0,0 +1,167 @@ +// 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.storage.endpoint; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; +import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; +import org.apache.cloudstack.engine.subsystem.api.storage.StorageAction; +import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; +import org.apache.cloudstack.storage.DummyEndpoint; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.cloud.host.dao.HostDao; +import com.cloud.utils.component.ComponentContext; +import com.cloud.vm.SecondaryStorageVm; +import com.cloud.vm.SecondaryStorageVmVO; +import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachine.State; +import com.cloud.vm.VirtualMachine.Type; +import com.cloud.vm.dao.SecondaryStorageVmDao; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(ComponentContext.class) +public class DefaultEndPointSelectorTest { + @Mock + HostDao _hostDao; + + @Mock + SecondaryStorageVmDao _ssvmDao; + + @InjectMocks + @Spy + DefaultEndPointSelector selector = new DefaultEndPointSelector(); + + //Special mocked endpoints that the tests can use to identify what was returned from the method. + private EndPoint selectMethodEndpoint = mock(EndPoint.class); + private DummyEndpoint dummyEndpoint = mock(DummyEndpoint.class); + + /** + * The single common method that sets up the mocks to cover all possible scenarios we want to + * test. The VM type and volume state are passed in, while a potential list of existing SSVMs + * are also passed in. As its final action, the method calls {@link DefaultEndPointSelector#select(DataObject, StorageAction)} + * in order to test the method's operation and returns the endpoint found. + * + * @param vmType - State of the VM attached to the volume + * @param volumeState - State of the volume + * @param ssvmVOs - A list of SSVMs to return from the DAO + * @return The selected endpoint. + */ + public EndPoint mockEndpointSelection(Type vmType, State volumeState, SecondaryStorageVmVO ... ssvmVOs) { --- End diff -- This method could be private. Did I missed something? Thanks. > System VM volumes cannot be deleted when there are no system VMs > ---------------------------------------------------------------- > > Key: CLOUDSTACK-9280 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9280 > Project: CloudStack > Issue Type: Bug > Security Level: Public(Anyone can view this level - this is the default.) > Components: Management Server > Affects Versions: 4.6.0, 4.7.0 > Reporter: Jeff Hair > > Scenario: When deleting a zone, everything under it must be removed. This results in the system VMs being destroyed as there are no more hosts running. > The storage cleanup thread properly detects that there are volumes to be deleted, but it cannot delete them because the endpoint selection fails with "No remote endpoint to send DeleteCommand, check if host or ssvm is down?" -- This message was sent by Atlassian JIRA (v6.3.4#6332)