From 0e18b5229c2299b57a6aec605d1ec62e51aa8417 Mon Sep 17 00:00:00 2001 From: liuliaozhong Date: Wed, 10 Jan 2024 14:09:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?ESB=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=BF=94=E5=9B=9E=E7=9A=84expres?= =?UTF-8?q?sion=E5=AD=97=E6=AE=B5=E4=B8=8D=E5=AF=B9=20#2724?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/bk/job/crontab/model/dto/CronJobInfoDTO.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/model/dto/CronJobInfoDTO.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/model/dto/CronJobInfoDTO.java index 0911958549..03572d94cc 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/model/dto/CronJobInfoDTO.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/model/dto/CronJobInfoDTO.java @@ -394,7 +394,7 @@ public static ServiceTemplateNotificationDTO buildNotifyInfo(CronJobInfoDTO cron // 结束前通知 notifyInfo.setTemplateCode(NotifyConsts.NOTIFY_TEMPLATE_CODE_BEFORE_CRON_JOB_END); variableMap.put("cron_type", "周期执行"); - String cronRuleStr = cronJobInfo.getCronExpression().substring(2).replace("?", "*"); + String cronRuleStr = CronExpressionUtil.fixExpressionForUser(cronJobInfo.getCronExpression()); variableMap.put("cron_rule", cronRuleStr); triggerTime = cronJobInfo.getEndTime() - cronJobInfo.getNotifyOffset(); variableMap.put("task.cron.repeat_freq", "周期执行"); @@ -445,7 +445,7 @@ public static ServiceTemplateNotificationDTO buildFailedNotifyInfo(CronJobInfoDT if (StringUtils.isNotBlank(cronJobInfo.getCronExpression())) { // 结束前通知 variableMap.put("task.cron.type", "周期执行"); - String cronRuleStr = cronJobInfo.getCronExpression().substring(2).replace("?", "*"); + String cronRuleStr = CronExpressionUtil.fixExpressionForUser(cronJobInfo.getCronExpression()); variableMap.put("task.cron.rule", cronRuleStr); variableMap.put("task.cron.repeat_freq", "周期执行"); variableMap.put("task.cron.time_set", cronRuleStr); @@ -483,7 +483,7 @@ public static EsbCronInfoV3DTO toEsbCronInfoV3(CronJobInfoDTO cronJobInfoDTO) { esbCronInfoResponse.setStatus(cronJobInfoDTO.getEnable() ? 1 : 0); if (StringUtils.isNotBlank(cronJobInfoDTO.getCronExpression())) { esbCronInfoResponse.setCronExpression( - cronJobInfoDTO.getCronExpression().substring(2).replace("?", "*")); + CronExpressionUtil.fixExpressionForUser(cronJobInfoDTO.getCronExpression())); } esbCronInfoResponse.setCreator(cronJobInfoDTO.getCreator()); esbCronInfoResponse.setCreateTime(cronJobInfoDTO.getCreateTime()); From b93f9e261b247bf89c2bd6d39c9bd59303f1dd5d Mon Sep 17 00:00:00 2001 From: liuliaozhong Date: Thu, 11 Jan 2024 11:42:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?ESB=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=BF=94=E5=9B=9E=E7=9A=84expres?= =?UTF-8?q?sion=E5=AD=97=E6=AE=B5=E4=B8=8D=E5=AF=B9=20#2724?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bk/job/api/constant/CronStatusEnum.java | 57 +++++ .../bk/job/api/constant/ErrorCode.java | 1 + .../tencent/bk/job/api/props/TestProps.java | 3 + .../tencent/bk/job/api/util/Operations.java | 23 ++ .../bk/job/api/v3/constants/APIV3Urls.java | 5 + .../request/EsbGetCronDetailV3Request.java | 51 ++++ .../request/EsbGetCronListV3Request.java | 150 +++++++++++ .../model/request/EsbSaveCronV3Request.java | 81 ++++++ .../request/EsbUpdateCronStatusV3Request.java | 49 ++++ .../api/v3/testcase/CronResourceAPITest.java | 236 ++++++++++++++++++ .../src/test/resources/test.properties | 1 + 11 files changed, 657 insertions(+) create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/constant/CronStatusEnum.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCronDetailV3Request.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCronListV3Request.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbSaveCronV3Request.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbUpdateCronStatusV3Request.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CronResourceAPITest.java diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/CronStatusEnum.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/CronStatusEnum.java new file mode 100644 index 0000000000..086914b2a5 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/CronStatusEnum.java @@ -0,0 +1,57 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.constant; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * 定时任务状态 + */ +public enum CronStatusEnum { + RUNNING(1), STOPPING(2); + + + @JsonValue + private final Integer status; + + CronStatusEnum(Integer status) { + this.status = status; + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static CronStatusEnum valOf(int cronStatus) { + for (CronStatusEnum status : values()) { + if (status.getStatus() == cronStatus) { + return status; + } + } + return null; + } + + public Integer getStatus() { + return status; + } +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/ErrorCode.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/ErrorCode.java index d381ee5a21..c3eeaf11aa 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/ErrorCode.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/ErrorCode.java @@ -30,6 +30,7 @@ public class ErrorCode { public static final int ILLEGAL_PARAM_WITH_PARAM_NAME = 1241005; //请求参数[]不合法 public static final int MISSING_OR_ILLEGAL_PARAM = 1241006; //请求参数缺失或不合法 public static final int MISSING_OR_ILLEGAL_PARAM_WITH_PARAM_NAME = 1241007; //请求参数[]缺失或不合法 + public static final int ILLEGAL_PARAM_WITH_PARAM_NAME_AND_REASON = 1241010; // 请求参数[0]不合法,原因:[1] public static final int SCRIPT_NOT_EXIST = 1243001;//脚本不存在 diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/props/TestProps.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/props/TestProps.java index 0552cc2372..66ddd2b94e 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/props/TestProps.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/props/TestProps.java @@ -93,6 +93,9 @@ private static void load() { // 用于测试的默认系统账号别名 public static final String DEFAULT_OS_ACCOUNT_ALIAS = getPropString("os.account.alias.default"); + // 定义默认的执行方案ID + public static final Long TASK_PLAN_DEFAULT_ID = getPropLong("task.plan.default.id"); + public static Integer getPropInteger(String key) { String value = props.getProperty(key); diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java index 95b6f7253e..528a549bd1 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java @@ -7,6 +7,7 @@ import com.tencent.bk.job.api.props.TestProps; import com.tencent.bk.job.api.v3.constants.APIV3Urls; import com.tencent.bk.job.api.v3.model.EsbAccountV3BasicDTO; +import com.tencent.bk.job.api.v3.model.EsbCronInfoV3DTO; import com.tencent.bk.job.api.v3.model.EsbDangerousRuleV3DTO; import com.tencent.bk.job.api.v3.model.EsbFileSourceV3DTO; import com.tencent.bk.job.api.v3.model.EsbJobExecuteV3DTO; @@ -24,6 +25,7 @@ import com.tencent.bk.job.api.v3.model.request.EsbFastExecuteScriptV3Request; import com.tencent.bk.job.api.v3.model.request.EsbFastTransferFileV3Request; import com.tencent.bk.job.api.v3.model.request.EsbManageDangerousRuleV3Req; +import com.tencent.bk.job.api.v3.model.request.EsbSaveCronV3Request; import io.restassured.common.mapper.TypeRef; import java.time.LocalDateTime; @@ -302,6 +304,27 @@ public static EsbJobExecuteV3DTO executePlanTask() { .getData(); } + public static EsbCronInfoV3DTO createCron() { + EsbSaveCronV3Request req = new EsbSaveCronV3Request(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setName(TestValueGenerator.generateUniqueStrValue("cron_task", 50)); + req.setCronExpression("* * * * *"); + req.setPlanId(TestProps.TASK_PLAN_DEFAULT_ID); + + return given() + .spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.SAVE_CRON) + .then() + .statusCode(200) + .extract() + .body() + .as(new TypeRef>() { + }) + .getData(); + } + private static String buildJobName() { return "api.test." + DateUtils.formatLocalDateTime(LocalDateTime.now(), "yyyyMMddhhmmssSSS"); } diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java index fa741fb2fd..cc093fbac3 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java @@ -64,4 +64,9 @@ public interface APIV3Urls { String EXECUTE_JOB_PLAN = "/api/job/v3/job-execute/execute_job_plan"; String GET_STEP_INSTANCE_DETAIL = "/api/job/v3/job-execute/get_step_instance_detail"; String GET_STEP_INSTANCE_STATUS = "/api/job/v3/job-execute/get_step_instance_status"; + + String SAVE_CRON = "/api/job/v3/job-crontab/save_cron"; + String GET_CRON_LIST = "/api/job/v3/job-crontab/get_cron_list"; + String UPDATE_CRON_STATUS = "/api/job/v3/job-crontab/update_cron_status"; + String GET_CRON_DETAIL = "/api/job/v3/job-crontab/get_cron_detail"; } diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCronDetailV3Request.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCronDetailV3Request.java new file mode 100644 index 0000000000..d8fa0283c8 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCronDetailV3Request.java @@ -0,0 +1,51 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.v3.model.request; + +import com.tencent.bk.job.api.model.EsbAppScopeReq; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @since 26/2/2020 16:29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class EsbGetCronDetailV3Request extends EsbAppScopeReq { + + /** + * 定时任务ID + *

+ * 如果存在则忽略其他筛选条件,只查询这个指定的作业信息 + */ + private Long id; + + public boolean validate() { + if (id == null || id <= 0) { + return false; + } + return true; + } +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCronListV3Request.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCronListV3Request.java new file mode 100644 index 0000000000..1b9e050a65 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCronListV3Request.java @@ -0,0 +1,150 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.v3.model.request; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.tencent.bk.job.api.model.EsbAppScopeReq; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.StringUtils; + +/** + * @since 26/2/2020 16:29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class EsbGetCronListV3Request extends EsbAppScopeReq { + + /** + * 定时作业名称 + */ + private String name; + + /** + * 定时任务ID + *

+ * 如果存在则忽略其他筛选条件,只查询这个指定的作业信息 + */ + private Long id; + + /** + * 定时作业状态 + *

+ * 1.已启动、2.已暂停 + */ + private Integer status; + + /** + * 定时作业创建人帐号 + */ + private String creator; + + /** + * 创建起始时间,毫秒时间戳 + */ + @JsonProperty("create_time_start") + private Long createTimeStart; + + /** + * 创建结束时间,毫秒时间戳 + */ + @JsonProperty("create_time_end") + private Long createTimeEnd; + + /** + * 作业修改人帐号 + */ + @JsonProperty("last_modify_user") + private String lastModifyUser; + + /** + * 最后修改起始时间,毫秒时间戳 + */ + @JsonProperty("last_modify_time_start") + private Long lastModifyTimeStart; + + /** + * 最后修改结束时间,毫秒时间戳 + */ + @JsonProperty("last_modify_time_end") + private Long lastModifyTimeEnd; + + /** + * 默认 0 表示从第 1 条记录开始返回 + */ + private Integer start; + + /** + * 返回记录数量,不传此参数默认返回 20 条 + */ + private Integer length; + + public boolean validate() { + + if (StringUtils.isEmpty(name)) { + name = null; + } + + if (status != null) { + if (status != 0 && status != 1) { + status = null; + } + } + + if (StringUtils.isEmpty(creator)) { + creator = null; + } + + if (createTimeStart == null || createTimeEnd == null) { + createTimeStart = null; + createTimeEnd = null; + } + + if (StringUtils.isEmpty(lastModifyUser)) { + lastModifyUser = null; + } + + if (lastModifyTimeStart == null || lastModifyTimeEnd == null) { + lastModifyTimeStart = null; + lastModifyTimeEnd = null; + } + + if (start == null || start < 0) { + start = 0; + } + + if (length == null || length < 0) { + length = 20; + } + + if (id != null && id > 0) { + return true; + } else { + id = null; + } + + return true; + } +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbSaveCronV3Request.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbSaveCronV3Request.java new file mode 100644 index 0000000000..72891a8bea --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbSaveCronV3Request.java @@ -0,0 +1,81 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.v3.model.request; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.tencent.bk.job.api.model.EsbAppScopeReq; +import com.tencent.bk.job.api.v3.model.EsbGlobalVarV3DTO; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @since 26/2/2020 16:33 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class EsbSaveCronV3Request extends EsbAppScopeReq { + + /** + * 定时任务ID,更新定时任务时,必须传这个值 + */ + private Long id; + + /** + * 要定时执行的作业的作业ID + */ + @JsonProperty("job_plan_id") + private Long planId; + + /** + * 定时作业名称,新建时必填,修改时选填 + */ + private String name; + + /** + * 定时任务的 cron 表达式 + *

+ * 新建时必填,修改时选填,各字段含义为:分 时 日 月 周,如: 0/5 * * * ? 表示每5分钟执行一次 + */ + @JsonProperty("expression") + private String cronExpression; + + /** + * 单次执行的指定执行时间(Unix时间戳) + *

+ * 不可与 cronExpression 同时为空 + */ + @JsonProperty("execute_time") + private Long executeTime; + + /** + * 定时任务的变量信息 + */ + @JsonProperty("global_var_list") + private List globalVarList; + + +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbUpdateCronStatusV3Request.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbUpdateCronStatusV3Request.java new file mode 100644 index 0000000000..e4a2251468 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbUpdateCronStatusV3Request.java @@ -0,0 +1,49 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.v3.model.request; + +import com.tencent.bk.job.api.model.EsbAppScopeReq; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @since 26/2/2020 16:33 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class EsbUpdateCronStatusV3Request extends EsbAppScopeReq { + + /** + * 定时作业 ID + */ + private Long id; + + /** + * 定时状态 + *

+ * 1.启动、2.暂停 + */ + private Integer status; +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CronResourceAPITest.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CronResourceAPITest.java new file mode 100644 index 0000000000..94b4e8c799 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CronResourceAPITest.java @@ -0,0 +1,236 @@ +package com.tencent.bk.job.api.v3.testcase; + +import com.tencent.bk.job.api.constant.CronStatusEnum; +import com.tencent.bk.job.api.constant.ErrorCode; +import com.tencent.bk.job.api.constant.ResourceScopeTypeEnum; +import com.tencent.bk.job.api.model.EsbResp; +import com.tencent.bk.job.api.props.TestProps; +import com.tencent.bk.job.api.util.ApiUtil; +import com.tencent.bk.job.api.util.JsonUtil; +import com.tencent.bk.job.api.util.Operations; +import com.tencent.bk.job.api.util.TestValueGenerator; +import com.tencent.bk.job.api.v3.constants.APIV3Urls; +import com.tencent.bk.job.api.v3.model.EsbCronInfoV3DTO; +import com.tencent.bk.job.api.v3.model.request.EsbGetCronDetailV3Request; +import com.tencent.bk.job.api.v3.model.request.EsbGetCronListV3Request; +import com.tencent.bk.job.api.v3.model.request.EsbSaveCronV3Request; +import com.tencent.bk.job.api.v3.model.request.EsbUpdateCronStatusV3Request; +import io.restassured.common.mapper.TypeRef; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.notNullValue; + +/** + * 定时作业管理 API 测试 + */ +@DisplayName("v3.CronResourceAPITest") +class CronResourceAPITest extends BaseTest { + + private static final List createdCronList = new ArrayList<>(); + + @AfterAll + static void tearDown() { + // cron没有清理接口,暂时忽略 + } + + @Nested + class CronCreateTest { + @Test + @DisplayName("测试定时作业正常创建") + void testCreateCron() { + EsbSaveCronV3Request req = new EsbSaveCronV3Request(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setName(TestValueGenerator.generateUniqueStrValue("cron_task", 50)); + req.setCronExpression("3 * * * 3"); + req.setPlanId(TestProps.TASK_PLAN_DEFAULT_ID); + + EsbCronInfoV3DTO createdCron = + given() + .spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.SAVE_CRON) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", greaterThan(0)) + .body("data.name", equalTo(req.getName())) + .body("data.status", equalTo(CronStatusEnum.STOPPING.getStatus())) + .body("data.bk_scope_type", equalTo(req.getScopeType())) + .body("data.bk_scope_id", equalTo(req.getScopeId())) + .body("data.expression", equalTo(req.getCronExpression())) + .body("data.creator", equalTo(TestProps.DEFAULT_TEST_USER)) + .body("data.create_time", greaterThan(0)) + .body("data.last_modify_user", equalTo(TestProps.DEFAULT_TEST_USER)) + .body("data.last_modify_time", greaterThan(0)) + .extract() + .body() + .as(new TypeRef>() { + }) + .getData(); + + createdCronList.add(createdCron); + } + + @Test + @DisplayName("创建定时作业异常场景测试") + void givenInvalidCreateCronThenFail() { + EsbSaveCronV3Request req = new EsbSaveCronV3Request(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setName(TestValueGenerator.generateUniqueStrValue("cron_task", 50)); + // 不是Unix格式的表达式 + req.setCronExpression("* 0/5 * * * * *"); + req.setPlanId(TestProps.TASK_PLAN_DEFAULT_ID); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.SAVE_CRON) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.ILLEGAL_PARAM_WITH_PARAM_NAME_AND_REASON)); + + // 执行方案id为null + req.setPlanId(null); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.SAVE_CRON) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.BAD_REQUEST)); + + // 定时作业名称为null + req.setName(null); + req.setPlanId(TestProps.TASK_PLAN_DEFAULT_ID); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.SAVE_CRON) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.BAD_REQUEST)); + } + } + + @Nested + class CronGetTest { + @Test + @DisplayName("测试获取定时作业列表") + void testGetCronList() { + EsbCronInfoV3DTO createdCron = Operations.createCron(); + createdCronList.add(createdCron); + EsbGetCronListV3Request req = new EsbGetCronListV3Request(); + req.setScopeId(createdCron.getScopeId()); + req.setScopeType(createdCron.getScopeType()); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.GET_CRON_LIST) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.total", greaterThan(0)); + } + + @Test + @DisplayName("测试获取定时作业详情") + void testGetCronDetail() { + EsbCronInfoV3DTO createdCron = Operations.createCron(); + createdCronList.add(createdCron); + EsbGetCronDetailV3Request req = new EsbGetCronDetailV3Request(); + req.setScopeId(createdCron.getScopeId()); + req.setScopeType(createdCron.getScopeType()); + req.setId(createdCron.getId()); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.GET_CRON_DETAIL) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", greaterThan(0)) + .body("data.name", equalTo(createdCron.getName())) + .body("data.bk_scope_type", equalTo(req.getScopeType())) + .body("data.bk_scope_id", equalTo(req.getScopeId())) + .body("data.expression", equalTo(createdCron.getCronExpression())) + .body("data.job_plan_id", equalTo(createdCron.getPlanId().intValue())) + .body("data.creator", equalTo(TestProps.DEFAULT_TEST_USER)) + .body("data.create_time", greaterThan(0)) + .body("data.last_modify_user", equalTo(TestProps.DEFAULT_TEST_USER)) + .body("data.last_modify_time", greaterThan(0)); + } + } + + @Nested + class CronUpdateTest { + // 更新操作 + @Test + @DisplayName("测试更新定时任务状态") + void testUpdateCronStatus() { + EsbCronInfoV3DTO createdCron = Operations.createCron(); + createdCronList.add(createdCron); + EsbUpdateCronStatusV3Request req = new EsbUpdateCronStatusV3Request(); + req.setScopeId(createdCron.getScopeId()); + req.setScopeType(createdCron.getScopeType()); + req.setId(createdCron.getId()); + // 启用 + req.setStatus(CronStatusEnum.RUNNING.getStatus()); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.UPDATE_CRON_STATUS) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", equalTo(req.getId().intValue())); + + // 停用 + req.setStatus(CronStatusEnum.STOPPING.getStatus()); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.UPDATE_CRON_STATUS) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", equalTo(req.getId().intValue())); + } + + // 更新定时任务 + @Test + @DisplayName("测试更新定时任务") + void testUpdateCron() { + EsbCronInfoV3DTO createdCron = Operations.createCron(); + createdCronList.add(createdCron); + + EsbSaveCronV3Request req = new EsbSaveCronV3Request(); + req.setId(createdCron.getId()); + req.setScopeId(createdCron.getScopeId()); + req.setScopeType(createdCron.getScopeType()); + req.setName(TestValueGenerator.generateUniqueStrValue("cron_task", 50)); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.SAVE_CRON) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", equalTo(req.getId().intValue())) + .body("data.name", equalTo(req.getName())) + .body("data.bk_scope_type", equalTo(req.getScopeType())) + .body("data.bk_scope_id", equalTo(req.getScopeId())); + + req.setName(null); + req.setCronExpression("* * * * *"); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.SAVE_CRON) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", equalTo(req.getId().intValue())) + .body("data.expression", equalTo(req.getCronExpression())) + .body("data.bk_scope_type", equalTo(req.getScopeType())) + .body("data.bk_scope_id", equalTo(req.getScopeId())); + } + } +} diff --git a/tests/openapi/src/test/resources/test.properties b/tests/openapi/src/test/resources/test.properties index c59481655c..cfe1fa66cf 100644 --- a/tests/openapi/src/test/resources/test.properties +++ b/tests/openapi/src/test/resources/test.properties @@ -20,3 +20,4 @@ biz.2.id=3 biz_set.default.id=9991001 test.user.default=admin os.account.alias.default=root +task.plan.default.id=1 From 89a9573406c405026e90a26116f50ea28451afc8 Mon Sep 17 00:00:00 2001 From: liuliaozhong Date: Thu, 11 Jan 2024 17:50:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?ESB=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=BF=94=E5=9B=9E=E7=9A=84expres?= =?UTF-8?q?sion=E5=AD=97=E6=AE=B5=E4=B8=8D=E5=AF=B9=20#2724?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/bk/job/api/props/TestProps.java | 3 -- .../tencent/bk/job/api/util/Operations.java | 34 +++++++++++++++++-- .../bk/job/api/v3/constants/APIV3Urls.java | 2 ++ .../v3/model/request/EsbBaseListRequest.java | 4 +-- .../api/v3/testcase/CronResourceAPITest.java | 26 ++++++++++++-- .../src/test/resources/test.properties | 1 - 6 files changed, 59 insertions(+), 11 deletions(-) diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/props/TestProps.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/props/TestProps.java index 66ddd2b94e..0552cc2372 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/props/TestProps.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/props/TestProps.java @@ -93,9 +93,6 @@ private static void load() { // 用于测试的默认系统账号别名 public static final String DEFAULT_OS_ACCOUNT_ALIAS = getPropString("os.account.alias.default"); - // 定义默认的执行方案ID - public static final Long TASK_PLAN_DEFAULT_ID = getPropLong("task.plan.default.id"); - public static Integer getPropInteger(String key) { String value = props.getProperty(key); diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java index 528a549bd1..4606b48476 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java @@ -11,6 +11,8 @@ import com.tencent.bk.job.api.v3.model.EsbDangerousRuleV3DTO; import com.tencent.bk.job.api.v3.model.EsbFileSourceV3DTO; import com.tencent.bk.job.api.v3.model.EsbJobExecuteV3DTO; +import com.tencent.bk.job.api.v3.model.EsbPageDataV3; +import com.tencent.bk.job.api.v3.model.EsbPlanBasicInfoV3DTO; import com.tencent.bk.job.api.v3.model.EsbScriptVersionDetailV3DTO; import com.tencent.bk.job.api.v3.model.EsbServerV3DTO; import com.tencent.bk.job.api.v3.model.HostDTO; @@ -24,6 +26,7 @@ import com.tencent.bk.job.api.v3.model.request.EsbExecuteJobV3Request; import com.tencent.bk.job.api.v3.model.request.EsbFastExecuteScriptV3Request; import com.tencent.bk.job.api.v3.model.request.EsbFastTransferFileV3Request; +import com.tencent.bk.job.api.v3.model.request.EsbGetPlanListV3Request; import com.tencent.bk.job.api.v3.model.request.EsbManageDangerousRuleV3Req; import com.tencent.bk.job.api.v3.model.request.EsbSaveCronV3Request; import io.restassured.common.mapper.TypeRef; @@ -305,13 +308,16 @@ public static EsbJobExecuteV3DTO executePlanTask() { } public static EsbCronInfoV3DTO createCron() { + Long planId = getTaskPlanId(); + if (planId == null) { + return null; + } EsbSaveCronV3Request req = new EsbSaveCronV3Request(); req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); req.setName(TestValueGenerator.generateUniqueStrValue("cron_task", 50)); req.setCronExpression("* * * * *"); - req.setPlanId(TestProps.TASK_PLAN_DEFAULT_ID); - + req.setPlanId(planId); return given() .spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) .body(JsonUtil.toJson(req)) @@ -325,6 +331,30 @@ public static EsbCronInfoV3DTO createCron() { .getData(); } + public static Long getTaskPlanId() { + EsbGetPlanListV3Request req = new EsbGetPlanListV3Request(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setLength(1); + EsbPageDataV3 data = given() + .spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.GET_JOB_PLAN_LIST) + .then() + .statusCode(200) + .extract() + .body() + .as(new TypeRef>>() { + }) + .getData(); + List planList = data.getData(); + if (planList != null && planList.size() > 0) { + EsbPlanBasicInfoV3DTO planBasicInfoV3DTO = planList.get(0); + return planBasicInfoV3DTO.getId(); + } + return null; + } + private static String buildJobName() { return "api.test." + DateUtils.formatLocalDateTime(LocalDateTime.now(), "yyyyMMddhhmmssSSS"); } diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java index cc093fbac3..4b2ebcd41b 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java @@ -69,4 +69,6 @@ public interface APIV3Urls { String GET_CRON_LIST = "/api/job/v3/job-crontab/get_cron_list"; String UPDATE_CRON_STATUS = "/api/job/v3/job-crontab/update_cron_status"; String GET_CRON_DETAIL = "/api/job/v3/job-crontab/get_cron_detail"; + + String GET_JOB_PLAN_LIST = "/api/job/v3/job-manage/get_job_plan_list"; } diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbBaseListRequest.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbBaseListRequest.java index 8bc4ee0731..fa9cf532a4 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbBaseListRequest.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbBaseListRequest.java @@ -1,13 +1,13 @@ package com.tencent.bk.job.api.v3.model.request; import com.fasterxml.jackson.annotation.JsonProperty; -import com.tencent.bk.job.api.model.BaseEsbReq; +import com.tencent.bk.job.api.model.EsbAppScopeReq; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -public class EsbBaseListRequest extends BaseEsbReq { +public class EsbBaseListRequest extends EsbAppScopeReq { /** * 业务 ID diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CronResourceAPITest.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CronResourceAPITest.java index 94b4e8c799..ed0721fcd1 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CronResourceAPITest.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CronResourceAPITest.java @@ -47,12 +47,16 @@ class CronCreateTest { @Test @DisplayName("测试定时作业正常创建") void testCreateCron() { + Long planId = Operations.getTaskPlanId(); + if (planId == null) { + return; + } EsbSaveCronV3Request req = new EsbSaveCronV3Request(); req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); req.setName(TestValueGenerator.generateUniqueStrValue("cron_task", 50)); req.setCronExpression("3 * * * 3"); - req.setPlanId(TestProps.TASK_PLAN_DEFAULT_ID); + req.setPlanId(planId); EsbCronInfoV3DTO createdCron = given() @@ -84,13 +88,17 @@ void testCreateCron() { @Test @DisplayName("创建定时作业异常场景测试") void givenInvalidCreateCronThenFail() { + Long planId = Operations.getTaskPlanId(); + if (planId == null) { + return; + } EsbSaveCronV3Request req = new EsbSaveCronV3Request(); req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); req.setName(TestValueGenerator.generateUniqueStrValue("cron_task", 50)); // 不是Unix格式的表达式 req.setCronExpression("* 0/5 * * * * *"); - req.setPlanId(TestProps.TASK_PLAN_DEFAULT_ID); + req.setPlanId(planId); given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) .body(JsonUtil.toJson(req)) .post(APIV3Urls.SAVE_CRON) @@ -107,7 +115,7 @@ void givenInvalidCreateCronThenFail() { // 定时作业名称为null req.setName(null); - req.setPlanId(TestProps.TASK_PLAN_DEFAULT_ID); + req.setPlanId(planId); given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) .body(JsonUtil.toJson(req)) .post(APIV3Urls.SAVE_CRON) @@ -122,6 +130,9 @@ class CronGetTest { @DisplayName("测试获取定时作业列表") void testGetCronList() { EsbCronInfoV3DTO createdCron = Operations.createCron(); + if (createdCron == null) { + return; + } createdCronList.add(createdCron); EsbGetCronListV3Request req = new EsbGetCronListV3Request(); req.setScopeId(createdCron.getScopeId()); @@ -139,6 +150,9 @@ void testGetCronList() { @DisplayName("测试获取定时作业详情") void testGetCronDetail() { EsbCronInfoV3DTO createdCron = Operations.createCron(); + if (createdCron == null) { + return; + } createdCronList.add(createdCron); EsbGetCronDetailV3Request req = new EsbGetCronDetailV3Request(); req.setScopeId(createdCron.getScopeId()); @@ -170,6 +184,9 @@ class CronUpdateTest { @DisplayName("测试更新定时任务状态") void testUpdateCronStatus() { EsbCronInfoV3DTO createdCron = Operations.createCron(); + if (createdCron == null) { + return; + } createdCronList.add(createdCron); EsbUpdateCronStatusV3Request req = new EsbUpdateCronStatusV3Request(); req.setScopeId(createdCron.getScopeId()); @@ -201,6 +218,9 @@ void testUpdateCronStatus() { @DisplayName("测试更新定时任务") void testUpdateCron() { EsbCronInfoV3DTO createdCron = Operations.createCron(); + if (createdCron == null) { + return; + } createdCronList.add(createdCron); EsbSaveCronV3Request req = new EsbSaveCronV3Request(); diff --git a/tests/openapi/src/test/resources/test.properties b/tests/openapi/src/test/resources/test.properties index cfe1fa66cf..c59481655c 100644 --- a/tests/openapi/src/test/resources/test.properties +++ b/tests/openapi/src/test/resources/test.properties @@ -20,4 +20,3 @@ biz.2.id=3 biz_set.default.id=9991001 test.user.default=admin os.account.alias.default=root -task.plan.default.id=1