Commit 95e8e55c by lepdou

update

parent c954dbd0
...@@ -41,9 +41,6 @@ public class ReleaseService { ...@@ -41,9 +41,6 @@ public class ReleaseService {
private AuditService auditService; private AuditService auditService;
@Autowired @Autowired
private NamespaceLockService namespaceLockService; private NamespaceLockService namespaceLockService;
@Autowired
private NamespaceService namespaceService;
public Release findOne(long releaseId) { public Release findOne(long releaseId) {
Release release = releaseRepository.findOne(releaseId); Release release = releaseRepository.findOne(releaseId);
...@@ -126,17 +123,11 @@ public class ReleaseService { ...@@ -126,17 +123,11 @@ public class ReleaseService {
String clusterName = release.getClusterName(); String clusterName = release.getClusterName();
String namespaceName = release.getNamespaceName(); String namespaceName = release.getNamespaceName();
Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName);
if (namespace == null) {
throw new BadRequestException(String.format("namespace not existed. (appId=%s, cluster=%s, namespace=%s)", appId,
clusterName, namespaceName));
}
PageRequest page = new PageRequest(0, 2); PageRequest page = new PageRequest(0, 2);
List<Release> twoLatestActiveReleases = findActiveReleases(appId, clusterName, namespaceName, page); List<Release> twoLatestActiveReleases = findActiveReleases(appId, clusterName, namespaceName, page);
if (twoLatestActiveReleases == null || twoLatestActiveReleases.size() < 2) { if (twoLatestActiveReleases == null || twoLatestActiveReleases.size() < 2) {
throw new BadRequestException(String.format( throw new BadRequestException(String.format(
"Can't rollback namespace(appId=%s, clusterName=%s, namespaceName=%s) because only one active release", appId, "Can't rollback namespace(appId=%s, clusterName=%s, namespaceName=%s) because there is only one active release", appId,
clusterName, clusterName,
namespaceName)); namespaceName));
} }
......
package com.ctrip.framework.apollo.biz.service; package com.ctrip.framework.apollo.biz.service;
import com.ctrip.framework.apollo.biz.AbstractUnitTest; import com.ctrip.framework.apollo.biz.AbstractUnitTest;
import com.ctrip.framework.apollo.biz.entity.Namespace;
import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.entity.Release;
import com.ctrip.framework.apollo.biz.repository.ReleaseRepository; import com.ctrip.framework.apollo.biz.repository.ReleaseRepository;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.core.exception.BadRequestException;
...@@ -34,7 +33,6 @@ public class ReleaseServiceTest extends AbstractUnitTest { ...@@ -34,7 +33,6 @@ public class ReleaseServiceTest extends AbstractUnitTest {
private String clusterName = "cluster-test"; private String clusterName = "cluster-test";
private String namespaceName = "namespace-test"; private String namespaceName = "namespace-test";
private String user = "user-test"; private String user = "user-test";
private Namespace namespace;
private long releaseId = 1; private long releaseId = 1;
private Release firstRelease; private Release firstRelease;
private Release secondRelease; private Release secondRelease;
...@@ -42,10 +40,6 @@ public class ReleaseServiceTest extends AbstractUnitTest { ...@@ -42,10 +40,6 @@ public class ReleaseServiceTest extends AbstractUnitTest {
@Before @Before
public void init() { public void init() {
namespace = new Namespace();
namespace.setAppId(appId);
namespace.setClusterName(clusterName);
namespace.setNamespaceName(namespaceName);
firstRelease = new Release(); firstRelease = new Release();
firstRelease.setId(releaseId); firstRelease.setId(releaseId);
...@@ -67,7 +61,6 @@ public class ReleaseServiceTest extends AbstractUnitTest { ...@@ -67,7 +61,6 @@ public class ReleaseServiceTest extends AbstractUnitTest {
public void testNamespaceNotExist() { public void testNamespaceNotExist() {
when(releaseRepository.findOne(releaseId)).thenReturn(firstRelease); when(releaseRepository.findOne(releaseId)).thenReturn(firstRelease);
when(namespaceService.findOne(appId, clusterName, namespaceName)).thenThrow(new BadRequestException("xx"));
releaseService.rollback(releaseId, user); releaseService.rollback(releaseId, user);
} }
...@@ -76,7 +69,6 @@ public class ReleaseServiceTest extends AbstractUnitTest { ...@@ -76,7 +69,6 @@ public class ReleaseServiceTest extends AbstractUnitTest {
public void testHasNoRelease() { public void testHasNoRelease() {
when(releaseRepository.findOne(releaseId)).thenReturn(firstRelease); when(releaseRepository.findOne(releaseId)).thenReturn(firstRelease);
when(namespaceService.findOne(appId, clusterName, namespaceName)).thenReturn(namespace);
when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(appId, when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(appId,
clusterName, clusterName,
namespaceName, namespaceName,
...@@ -90,7 +82,6 @@ public class ReleaseServiceTest extends AbstractUnitTest { ...@@ -90,7 +82,6 @@ public class ReleaseServiceTest extends AbstractUnitTest {
public void testRollback() { public void testRollback() {
when(releaseRepository.findOne(releaseId)).thenReturn(firstRelease); when(releaseRepository.findOne(releaseId)).thenReturn(firstRelease);
when(namespaceService.findOne(appId, clusterName, namespaceName)).thenReturn(namespace);
when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(appId, when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(appId,
clusterName, clusterName,
namespaceName, namespaceName,
......
...@@ -384,7 +384,7 @@ ...@@ -384,7 +384,7 @@
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button> <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-danger" ng-if="releaseCompareResult.length > 0" <button type="submit" class="btn btn-danger" ng-if="releaseCompareResult.length > 0"
ng-disabled="rollbackBtnDisabled">回滚 ng-disabled="rollbackBtnDisabled">确定回滚
</button> </button>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment