Skip to content

Commit

Permalink
add schedule e2e
Browse files Browse the repository at this point in the history
Signed-off-by: ii2day <ji.li@daocloud.io>
  • Loading branch information
ii2day committed Aug 22, 2023
1 parent afe5513 commit ed7cb4e
Show file tree
Hide file tree
Showing 11 changed files with 1,085 additions and 34 deletions.
20 changes: 10 additions & 10 deletions docs/reference/apphttphealthy-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ status:
#### AgentSpec
| 字段 | 描述 | 结构 | 验证 | 取值 | 默认值 |
|-------------------------------|------------------------|----------------------------------------------------------------------------------------------------------------------------------------|-----|----------------------|-----------|
| annotation | agent 工作负载的 annotation | map[string]string | 可选 | | |
| kind | agent 工作负载的类型 | string | 可选 | Deployment、DaemonSet | DaemonSet |
| deploymentReplicas | agent 工作负载类型为 deployment 时的期望副本数 | int | 可选 | 大于等于 0 | 0 |
| affinity | agent 工作负载亲和性 | [labelSelector](https://github.com/kubernetes/kubernetes/blob/v1.27.0/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L1195) | 可选 | | |
| env | agent 工作负载环境变量 | [env](https://github.com/kubernetes/kubernetes/blob/v1.27.0/staging/src/k8s.io/api/core/v1/types.go#L2012) | 可选 | | |
| hostNetwork | agent 工作负载是否使用宿主机网络 | bool | 可选 | true、false | false |
| resources | agent 工作负载资源使用配置 | [resources](https://github.com/kubernetes/kubernetes/blob/v1.27.0/staging/src/k8s.io/api/core/v1/types.go#L2333) | 可选 | | |
| terminationGracePeriodMinutes | agent 工作负载完成任务后多少分钟之后终止 | int | 可选 | 大于等于 0 | 60 |
| 字段 | 描述 | 结构 | 验证 | 取值 | 默认值 |
|-------------------------------|------------------------|----------------------------------------------------------------------------------------------------------------------------------------|-----|----------------------|--------------------|
| annotation | agent 工作负载的 annotation | map[string]string | 可选 | | |
| kind | agent 工作负载的类型 | string | 可选 | Deployment、DaemonSet | DaemonSet |
| deploymentReplicas | agent 工作负载类型为 deployment 时的期望副本数 | int | 可选 | 大于等于 0 | 0 |
| affinity | agent 工作负载亲和性 | [labelSelector](https://github.com/kubernetes/kubernetes/blob/v1.27.0/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L1195) | 可选 | | |
| env | agent 工作负载环境变量 | [env](https://github.com/kubernetes/kubernetes/blob/v1.27.0/staging/src/k8s.io/api/core/v1/types.go#L2012) | 可选 | | |
| hostNetwork | agent 工作负载是否使用宿主机网络 | bool | 可选 | true、false | false |
| resources | agent 工作负载资源使用配置 | [resources](https://github.com/kubernetes/kubernetes/blob/v1.27.0/staging/src/k8s.io/api/core/v1/types.go#L2333) | 可选 | | cpu:100m,memory:128Mi |
| terminationGracePeriodMinutes | agent 工作负载完成任务后多少分钟之后终止 | int | 可选 | 大于等于 0 | 60 |
#### Schedule
Expand Down
26 changes: 26 additions & 0 deletions docs/reference/runtime-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## runtime

当下发任务 CR 后,kdoctor-controller 会根据 CR 中的 AgentSpec 生成对应的任务载体(DaemonSet 或 Deployment)执行任务,每一个任务独立使用一个载体。

### 载体资源

当任务 CR 下发后,kdocotr-controller 会创建如下资源进行任务。

### 工作负载

工作负载为 DaemonSet 或 Deployment,默认为 Daemonset,负载中的每一个 Pod 根据任务配置进行的请求,并将执行结果落盘到 Pod 中,可通过 AgentSpec 中设置
工作负载的销毁时间,默认任务执行完 60 分钟后,销毁工作负载,当删除 CR 任务时,工作负载会一并被删除。

### Service

在创建工作负载时,kdoctor-controller 同时会根据 IP Family 的配置,创建对应的 service 并于工作负载的 pod 绑定。用于测试 service 网络连通性。与工作负载
的销毁逻辑相同。

### Ingress

当任务为 NetReach 时,若测试目标包含 Ingress 时,会创建一个 Ingress,用于测试 Ingress 的网络联通性,与工作负载的销毁逻辑相同。

### 报告收取

当任务 CR 下发后,kdoctor-controller 会将任务注册进 ReportManager,ReportManager 会定期去每一个任务负载中通过 GRPC 接口获取报告,并聚合
在 kdoctor-controller 中,聚合后可通过命令 `kubectl get kdoctorreport` 获取报告结果,因此,若报告未收集完成就将工作负载删除将影响报告聚合结果。
15 changes: 13 additions & 2 deletions pkg/reportManager/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *reportManager) syncReportFromOneAgent(ctx context.Context, logger *zap.

}

func (s *reportManager) runControllerAggregateReportOnce(ctx context.Context, logger *zap.Logger) error {
func (s *reportManager) runControllerAggregateReportOnce(ctx context.Context, logger *zap.Logger, taskName string) error {

Check warning on line 90 in pkg/reportManager/worker.go

View check run for this annotation

Codecov / codecov/patch

pkg/reportManager/worker.go#L90

Added line #L90 was not covered by tests

// grpc client
grpcClient := grpcManager.NewGrpcClient(s.logger.Named("grpc"), true)
Expand All @@ -108,6 +108,10 @@ func (s *reportManager) runControllerAggregateReportOnce(ctx context.Context, lo
logger.Sugar().Debugf("task %s runtime %s status %s not created finish", m.TaskName, m.RuntimeName, m.RuntimeStatus)
continue

Check warning on line 109 in pkg/reportManager/worker.go

View check run for this annotation

Codecov / codecov/patch

pkg/reportManager/worker.go#L102-L109

Added lines #L102 - L109 were not covered by tests
}
if m.TaskName != taskName {
logger.Sugar().Debugf("this agent %s is not ccurrent sync task %s ,skip ", m.RuntimeName, taskName)
continue

Check warning on line 113 in pkg/reportManager/worker.go

View check run for this annotation

Codecov / codecov/patch

pkg/reportManager/worker.go#L111-L113

Added lines #L111 - L113 were not covered by tests
}
var podIP k8sObjManager.PodIps
var err error
if m.RuntimeKind == types.KindDaemonSet {
Expand Down Expand Up @@ -161,5 +165,12 @@ func (s *reportManager) syncHandler(ctx context.Context, triggerName string) err
logger := s.logger.With(
zap.String("triggerSource", triggerName),
)
return s.runControllerAggregateReportOnce(ctx, logger)
var taskName string
if triggerName == "periodicallyTrigger" {
taskName = triggerName
} else {
taskName = strings.Split(triggerName, ".")[1]
}

Check warning on line 173 in pkg/reportManager/worker.go

View check run for this annotation

Codecov / codecov/patch

pkg/reportManager/worker.go#L168-L173

Added lines #L168 - L173 were not covered by tests

return s.runControllerAggregateReportOnce(ctx, logger, taskName)

Check warning on line 175 in pkg/reportManager/worker.go

View check run for this annotation

Codecov / codecov/patch

pkg/reportManager/worker.go#L175

Added line #L175 was not covered by tests
}
23 changes: 14 additions & 9 deletions test/docs/Runtime.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# E2E Cases for Task Runtime

| Case ID | Title | Priority | Smoke | Status | Other |
|---------|----------------------------------------------------------------------------------------|----------|-------|--------|-------------|
| E00001 | Successfully testing Task Runtime DaemonSet creation | p1 | | | |
| E00002 | Successfully testing Task Runtime Deployment creation | p1 | | | |
| E00003 | Successfully testing Task Runtime Service creation | p1 | | | |
| E00004 | Successfully testing cascading deletion with Task Runtime Service | p1 | | | |
| E00005 | Successfully testing cascading deletion with Task Runtime | p1 | | | |
| E00006 | Successfully testing Task NetReach Runtime Service and Ingress creation | p1 | | | |
| E00007 | Successfully testing cascading deletion with Task NetReach Runtime Service and Ingress | p1 | | | |
| Case ID | Title | Priority | Smoke | Status | Other |
|---------|------------------------------------------------------------------------------------------------|----------|-------|--------|-------------|
| E00001 | Successfully testing Task NetReach Runtime DaemonSet Service Ingress creation | p1 | | done | |
| E00002 | Successfully testing Task NetAppHttpHealthy Runtime DaemonSet Service creation | p1 | | done | |
| E00003 | Successfully testing Task NetDns Runtime DaemonSet Service creation | p1 | | done | |
| E00004 | Successfully testing Task NetReach Runtime Deployment Service Ingress creation | p1 | | | |
| E00005 | Successfully testing Task NetAppHttpHealthy Runtime Deployment Service creation | p1 | | | |
| E00006 | Successfully testing Task NetDns Runtime Deployment Service creation | p1 | | | |
| E00007 | Successfully testing cascading deletion with Task NetReach DaemonSet Service and Ingress | p1 | | done | |
| E00008 | Successfully testing cascading deletion with Task NetAppHttpHealthy DaemonSet Service | p1 | | done | |
| E00009 | Successfully testing cascading deletion with Task NetDns DaemonSet Service | p1 | | done | |
| E00010 | Successfully testing cascading deletion with Task NetReach Deployment Service and Ingress | p1 | | | |
| E00011 | Successfully testing cascading deletion with Task NetAppHttpHealthy Deployment Service | p1 | | | |
| E00012 | Successfully testing cascading deletion with Task NetDns Deployment Service | p1 | | | |
Loading

0 comments on commit ed7cb4e

Please sign in to comment.