sap-cloud-platform - 如何测试应用程序的弹性
问题描述
我们在 SAP Cloud Platform Cloud Foundry 上运行了一个云应用程序,它利用了其他重用服务,例如审计服务
为了测试弹性,我们需要模拟重用服务的停止
您能否分享一些指导如何实现这一目标?
问候, Apoorv
解决方案
按照教程Introduce Resilience to your Application,他们在他们的应用程序中添加了一个测试,为了模拟被调用服务的问题,他们只是指向一个不存在的目的地。
他们介绍的测试是:
@Test
public void testWithFallback() {
// Simulate a failed VDM call with non-existent destination
DestinationAccessor.setLoader((n, o) -> Try.success(dummyDestination));
// Assure an empty list is returned as fallback
when()
.get("/businesspartners")
.then()
.statusCode(200)
.contentType(ContentType.JSON)
.body("", Matchers.hasSize(0));
}
目的地定义为:
private static final String DESTINATION_NAME = "MyErpSystem";
private static final Destination dummyDestination = DefaultDestination.builder().property("name", DESTINATION_NAME).property("URL", "foo").build();
希望这可以帮助您朝着正确的方向前进。
氪,凯派
推荐阅读
- arrays - 为什么它不显示添加到数组中的项目?
- flutter - 在 Google Play 上部署一个移动 Flutter 应用程序作为生产
- python - Python 混乱
- python-3.x - Pyinstaller 不包括 google-api-python-client
- mysql - 在 MYSQL 中使用递归时的多个结果集
- ubuntu-18.04 - 如何将 DigitalOcean 液滴传输到另一台主机
- python - 无法在 Ubuntu 20.04 上通过 pip 安装任何软件包 - SSL 错误
- php - 如何在 Google Cloud 上将 PHP 7.0.27 升级到 7.3?
- python - 在脚本中运行子进程并根据输出,继续执行脚本
- database - 并发 INSERT 抛出 SQLException 错误:重复键值违反唯一约束 Hibernate