【发布时间】:2020-12-05 12:23:04
【问题描述】:
我在src/intrgTest/groovy 位置下对我的 Spring Boot 应用程序进行了简单的集成测试,下面是测试
@AutoConfigureMockMvc
@WebMvcTest
class WebControllerTest extends Specification {
@Autowired
private MockMvc mvc
def "when get is performed then the response has status 200 and content is 'Hello world!'"() {
expect: "Status is 200 and the response is 'Hello world!'"
mvc.perform(get("/hello"))
.andExpect(status().isOk())
.andReturn()
.response
.contentAsString == "Hello world!"
}
}
当我在 Kubernetes 中创建一个 pod 时,我想运行这个测试用例来检查应用程序是否正常工作。我怎样才能做到这一点?
下面是 Kubernetes 的 deployment.yml 文件
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: spring-boot-deployment
spec:
selector:
matchLabels:
app: spring-boot-app
replicas: 2
template:
metadata:
labels:
app: spring-boot-app
spec:
containers:
- name: spring-boot-app
image: spring-boot-test-images:63
ports:
- containerPort: 80
【问题讨论】:
标签: spring-boot docker kubernetes integration-testing