mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
parent
4bd0b1c24f
commit
43ab8a9367
@ -81,6 +81,20 @@ public class KubernetesVersionManagerImpl extends ManagerBase implements Kuberne
|
||||
|
||||
public static final String MINIMUN_AUTOSCALER_SUPPORTED_VERSION = "1.15.0";
|
||||
|
||||
protected void updateTemplateDetailsInKubernetesSupportedVersionResponse(
|
||||
final KubernetesSupportedVersion kubernetesSupportedVersion, KubernetesSupportedVersionResponse response) {
|
||||
TemplateJoinVO template = templateJoinDao.findById(kubernetesSupportedVersion.getIsoId());
|
||||
if (template == null) {
|
||||
return;
|
||||
}
|
||||
response.setIsoId(template.getUuid());
|
||||
response.setIsoName(template.getName());
|
||||
if (template.getState() != null) {
|
||||
response.setIsoState(template.getState().toString());
|
||||
}
|
||||
response.setDirectDownload(template.isDirectDownload());
|
||||
}
|
||||
|
||||
private KubernetesSupportedVersionResponse createKubernetesSupportedVersionResponse(final KubernetesSupportedVersion kubernetesSupportedVersion) {
|
||||
KubernetesSupportedVersionResponse response = new KubernetesSupportedVersionResponse();
|
||||
response.setObjectName("kubernetessupportedversion");
|
||||
@ -100,13 +114,7 @@ public class KubernetesVersionManagerImpl extends ManagerBase implements Kuberne
|
||||
response.setSupportsHA(compareSemanticVersions(kubernetesSupportedVersion.getSemanticVersion(),
|
||||
KubernetesClusterService.MIN_KUBERNETES_VERSION_HA_SUPPORT)>=0);
|
||||
response.setSupportsAutoscaling(versionSupportsAutoscaling(kubernetesSupportedVersion));
|
||||
TemplateJoinVO template = templateJoinDao.findById(kubernetesSupportedVersion.getIsoId());
|
||||
if (template != null) {
|
||||
response.setIsoId(template.getUuid());
|
||||
response.setIsoName(template.getName());
|
||||
response.setIsoState(template.getState().toString());
|
||||
response.setDirectDownload(template.isDirectDownload());
|
||||
}
|
||||
updateTemplateDetailsInKubernetesSupportedVersionResponse(kubernetesSupportedVersion, response);
|
||||
response.setCreated(kubernetesSupportedVersion.getCreated());
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
// 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 com.cloud.kubernetes.version;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.cloudstack.api.response.KubernetesSupportedVersionResponse;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.cloud.api.query.dao.TemplateJoinDao;
|
||||
import com.cloud.api.query.vo.TemplateJoinVO;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class KubernetesVersionManagerImplTest {
|
||||
|
||||
@Mock
|
||||
TemplateJoinDao templateJoinDao;
|
||||
|
||||
@InjectMocks
|
||||
KubernetesVersionManagerImpl kubernetesVersionManager = new KubernetesVersionManagerImpl();
|
||||
|
||||
@Test
|
||||
public void testUpdateTemplateDetailsInKubernetesSupportedVersionResponseNullTemplate() {
|
||||
KubernetesSupportedVersion kubernetesSupportedVersion = Mockito.mock(KubernetesSupportedVersion.class);
|
||||
Mockito.when(kubernetesSupportedVersion.getIsoId()).thenReturn(1L);
|
||||
KubernetesSupportedVersionResponse response = new KubernetesSupportedVersionResponse();
|
||||
kubernetesVersionManager.updateTemplateDetailsInKubernetesSupportedVersionResponse(kubernetesSupportedVersion,
|
||||
response);
|
||||
Assert.assertNull(ReflectionTestUtils.getField(response, "isoId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateTemplateDetailsInKubernetesSupportedVersionResponseValidTemplate() {
|
||||
KubernetesSupportedVersion kubernetesSupportedVersion = Mockito.mock(KubernetesSupportedVersion.class);
|
||||
Mockito.when(kubernetesSupportedVersion.getIsoId()).thenReturn(1L);
|
||||
KubernetesSupportedVersionResponse response = new KubernetesSupportedVersionResponse();
|
||||
TemplateJoinVO templateJoinVO = Mockito.mock(TemplateJoinVO.class);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Mockito.when(templateJoinVO.getUuid()).thenReturn(uuid);
|
||||
Mockito.when(templateJoinDao.findById(1L)).thenReturn(templateJoinVO);
|
||||
kubernetesVersionManager.updateTemplateDetailsInKubernetesSupportedVersionResponse(kubernetesSupportedVersion,
|
||||
response);
|
||||
Assert.assertEquals(uuid, ReflectionTestUtils.getField(response, "isoId"));
|
||||
Assert.assertNull(ReflectionTestUtils.getField(response, "isoState"));
|
||||
ObjectInDataStoreStateMachine.State state = ObjectInDataStoreStateMachine.State.Ready;
|
||||
Mockito.when(templateJoinVO.getState()).thenReturn(state);
|
||||
kubernetesVersionManager.updateTemplateDetailsInKubernetesSupportedVersionResponse(kubernetesSupportedVersion,
|
||||
response);
|
||||
Assert.assertEquals(state.toString(), ReflectionTestUtils.getField(response, "isoState"));
|
||||
}
|
||||
}
|
||||
@ -332,8 +332,9 @@ export default {
|
||||
this.zoneLoading = true
|
||||
params.showicon = true
|
||||
api('listZones', params).then(json => {
|
||||
const listZones = json.listzonesresponse.zone
|
||||
var listZones = json.listzonesresponse.zone
|
||||
if (listZones) {
|
||||
listZones = listZones.filter(x => x.allocationstate === 'Enabled')
|
||||
this.zones = this.zones.concat(listZones)
|
||||
}
|
||||
}).finally(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user