@@ -14,10 +14,16 @@ import { TestEnvironment } from "../../../../../../__tests__/__src__/environment
14
14
import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema" ;
15
15
import { JobTestsUtils } from "../../../../../zosjobs/__tests__/__system__/JobTestsUtils" ;
16
16
import { IO } from "@zowe/imperative" ;
17
+ import { DeleteJobs , IJob } from "@zowe/zos-jobs-for-zowe-sdk" ;
18
+ import { Session } from "@zowe/imperative" ;
17
19
18
20
// Test Environment populated in the beforeAll();
21
+ let REAL_SESSION : Session ;
19
22
let TEST_ENVIRONMENT : ITestEnvironment < ITestPropertiesSchema > ;
20
23
const LOCAL_JCL_FILE : string = __dirname + "/" + "testFileOfLocalJCL.txt" ;
24
+ const jobsToDelete = new Map < string , string > ( ) ;
25
+ const jobDataRegexV1 = / S u c c e s s f u l l y s u b m i t t e d r e q u e s t t o c a n c e l j o b ( \w + ) \( ( J O B \d + ) \) / ;
26
+ const jobNameRegexV1 = / j o b ( \w + ) / i;
21
27
22
28
describe ( "zos-jobs cancel job command" , ( ) => {
23
29
// Create the unique test environment
@@ -28,6 +34,8 @@ describe("zos-jobs cancel job command", () => {
28
34
} ) ;
29
35
const systemProps = TEST_ENVIRONMENT . systemTestProperties ;
30
36
37
+ REAL_SESSION = TestEnvironment . createZosmfSession ( TEST_ENVIRONMENT ) ;
38
+
31
39
const jcl = JobTestsUtils . getSleepJCL ( systemProps . zosmf . user , systemProps . tso . account , systemProps . zosjobs . jobclass ) ;
32
40
const bufferJCL : Buffer = Buffer . from ( jcl ) ;
33
41
IO . createFileSync ( LOCAL_JCL_FILE ) ;
@@ -36,6 +44,9 @@ describe("zos-jobs cancel job command", () => {
36
44
37
45
afterAll ( async ( ) => {
38
46
IO . deleteFile ( LOCAL_JCL_FILE ) ;
47
+ for ( const [ jobname , jobid ] of jobsToDelete ) {
48
+ await DeleteJobs . deleteJob ( REAL_SESSION , jobname , jobid ) ;
49
+ }
39
50
} ) ;
40
51
41
52
describe ( "error handling" , ( ) => {
@@ -67,10 +78,20 @@ describe("zos-jobs cancel job command", () => {
67
78
68
79
describe ( "successful scenario" , ( ) => {
69
80
it ( "should cancel a job v1" , ( ) => {
70
- const response = runCliScript ( __dirname + "/__scripts__/job/cancel_job_v1.sh" , TEST_ENVIRONMENT , [ LOCAL_JCL_FILE ] ) ;
71
- expect ( response . stderr . toString ( ) ) . toBe ( "" ) ;
72
- expect ( response . status ) . toBe ( 0 ) ;
73
- expect ( response . stdout . toString ( ) ) . toContain ( "Successfully submitted request to cancel job" ) ;
81
+ if ( TEST_ENVIRONMENT . systemTestProperties . zosjobs . skipCIM ) {
82
+ process . stdout . write ( "Skipping test because skipCIM is set." ) ;
83
+ } else {
84
+ const response = runCliScript ( __dirname + "/__scripts__/job/cancel_job_v1.sh" , TEST_ENVIRONMENT , [ LOCAL_JCL_FILE ] ) ;
85
+
86
+ expect ( response . stderr . toString ( ) ) . toBe ( "" ) ;
87
+ expect ( response . status ) . toBe ( 0 ) ;
88
+ expect ( response . stdout . toString ( ) ) . toContain ( "Successfully submitted request to cancel job" ) ;
89
+
90
+ const jobname = response . stdout . toString ( ) . match ( jobNameRegexV1 ) . pop ( ) ;
91
+ const jobid = response . stdout . toString ( ) . match ( jobDataRegexV1 ) . pop ( ) ;
92
+
93
+ jobsToDelete . set ( jobname , jobid ) ;
94
+ }
74
95
} ) ;
75
96
76
97
it ( "should cancel a job v2" , ( ) => {
@@ -108,18 +129,27 @@ describe("zos-jobs cancel job command", () => {
108
129
} ) ;
109
130
110
131
it ( "cancel a job without a profile 1.0" , async ( ) => {
111
- const response = runCliScript ( __dirname + "/__scripts__/job/cancel_job_v1_fully_qualified.sh" ,
112
- TEST_ENVIRONMENT_NO_PROF ,
113
- [
114
- LOCAL_JCL_FILE ,
115
- DEFAULT_SYSTEM_PROPS . zosmf . host ,
116
- DEFAULT_SYSTEM_PROPS . zosmf . port ,
117
- DEFAULT_SYSTEM_PROPS . zosmf . user ,
118
- DEFAULT_SYSTEM_PROPS . zosmf . password ,
119
- ] ) ;
120
- expect ( response . stderr . toString ( ) ) . toBe ( "" ) ;
121
- expect ( response . status ) . toBe ( 0 ) ;
122
- expect ( response . stdout . toString ( ) ) . toContain ( "Successfully submitted request to cancel job" ) ;
132
+ if ( TEST_ENVIRONMENT . systemTestProperties . zosjobs . skipCIM ) {
133
+ process . stdout . write ( "Skipping test because skipCIM is set." ) ;
134
+ } else {
135
+ const response = runCliScript ( __dirname + "/__scripts__/job/cancel_job_v1_fully_qualified.sh" ,
136
+ TEST_ENVIRONMENT_NO_PROF ,
137
+ [
138
+ LOCAL_JCL_FILE ,
139
+ DEFAULT_SYSTEM_PROPS . zosmf . host ,
140
+ DEFAULT_SYSTEM_PROPS . zosmf . port ,
141
+ DEFAULT_SYSTEM_PROPS . zosmf . user ,
142
+ DEFAULT_SYSTEM_PROPS . zosmf . password ,
143
+ ] ) ;
144
+ expect ( response . stderr . toString ( ) ) . toBe ( "" ) ;
145
+ expect ( response . status ) . toBe ( 0 ) ;
146
+ expect ( response . stdout . toString ( ) ) . toContain ( "Successfully submitted request to cancel job" ) ;
147
+
148
+ const jobname = response . stdout . toString ( ) . match ( jobNameRegexV1 ) . pop ( ) ;
149
+ const jobid = response . stdout . toString ( ) . match ( jobDataRegexV1 ) . pop ( ) ;
150
+
151
+ jobsToDelete . set ( jobname , jobid ) ;
152
+ }
123
153
} ) ;
124
154
125
155
it ( "cancel a job without a profile 2.0" , async ( ) => {
0 commit comments