Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System tests should cleanup after themselves #2216

Merged
merged 77 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
d993866
keeping track of resources created during tests and adding cleanup
ATorrise Aug 6, 2024
3b01d28
tests that ive been preoccupied with
ATorrise Aug 14, 2024
fb156de
fixing these was hardgit add .
ATorrise Aug 15, 2024
960777b
ensuring more tests delete jobs from mf, also fixing delete operations
ATorrise Aug 15, 2024
68a7fdd
Merge remote-tracking branch 'origin/next' into system-test-cleanup
ATorrise Aug 15, 2024
4f059e6
finished zosjobs sdk tests and starting zosfiles sdk tests
ATorrise Aug 16, 2024
81048a7
modifying upload.system.test took the longest... removing some test f…
ATorrise Aug 21, 2024
a505c0d
took awhile to see the difference in regex between v1 and v2 that i w…
ATorrise Aug 22, 2024
56f0e9a
providing more clarity in a comment about calculating previous jobid
ATorrise Aug 22, 2024
c458433
fixing cli.zos-jobs.download and its accompanying scripts
ATorrise Aug 22, 2024
e356ac8
more cli sytem tests and ammended shell scripts
ATorrise Aug 22, 2024
123c7f9
finishin clizosjobslistspoolfiles
ATorrise Aug 22, 2024
d7b2840
fixing submit with a different, less intensive cleanup approach
ATorrise Aug 22, 2024
e1f2ca2
realizing need to keep createZosmfSession for uss files..
ATorrise Aug 23, 2024
4ccaad5
finishing cliZosjobsSubmit
ATorrise Aug 23, 2024
c5995dd
fixing error in variable name across files and finishing view spool t…
ATorrise Aug 23, 2024
a0fa936
unable to modify file like others
ATorrise Aug 26, 2024
f746a0b
deletes remaining ds from mf
ATorrise Aug 26, 2024
885a28a
Merge branch 'next' into system-test-cleanup
ATorrise Aug 26, 2024
f334c76
Update cli.zos-jobs.submit.stdin.system.test.ts to remove semicolon
ATorrise Aug 26, 2024
e11726f
Update cli.zos-jobs.submit.stdin.system.test.ts removing accidental line
ATorrise Aug 26, 2024
70cb522
whoops
ATorrise Aug 26, 2024
d87f789
Merge branch 'next' into system-test-cleanup
ATorrise Aug 26, 2024
0b475ac
changelog
ATorrise Aug 27, 2024
3853c8a
linting
ATorrise Aug 27, 2024
0159d2c
Merge branch 'next' into system-test-cleanup
ATorrise Aug 28, 2024
c7de80c
no circ dependency error?
ATorrise Aug 28, 2024
54baa2d
updating changelog
ATorrise Aug 28, 2024
ebe3570
moving things around with andrew's help
ATorrise Aug 28, 2024
663340f
moving around things in testEnv and ITestEnv
ATorrise Aug 28, 2024
9d59e1a
about to make a really big change
ATorrise Aug 29, 2024
fe2c72b
restoring clitestutils cleanup()
ATorrise Aug 29, 2024
46677f7
Merge branch 'next' into system-test-cleanup
ATorrise Aug 29, 2024
21bf9aa
fixing other testEnv
ATorrise Aug 29, 2024
a9d2865
updating imports
ATorrise Aug 29, 2024
52361c2
fixing imports
ATorrise Aug 29, 2024
309be62
hopefully not breaking
ATorrise Aug 29, 2024
585bb75
accidentally left 1 thing out of if statement
ATorrise Aug 29, 2024
a83444a
whoops
ATorrise Aug 29, 2024
bc1ffa2
making a wait util method and implementing it everywhere
ATorrise Aug 29, 2024
8ccb8f4
addressing one of fernandos comments
ATorrise Aug 30, 2024
842ee6b
timeout corrections
ATorrise Aug 30, 2024
9e8f22e
removing change to a unit test
ATorrise Aug 30, 2024
1c7a5b2
changing system test to work with 'any' job name
ATorrise Aug 30, 2024
83faac9
wiping testEnvironment.resources in cleanup
ATorrise Sep 4, 2024
6c7064b
changing the way the test works but need testing mini to be active an…
ATorrise Sep 4, 2024
deb5cfa
Merge branch 'next' into system-test-cleanup
ATorrise Sep 4, 2024
cefbff1
hopefully good to merge now
ATorrise Sep 4, 2024
aaa43b8
Merge branch 'system-test-cleanup' of https://github.com/zowe/zowe-cl…
ATorrise Sep 4, 2024
201ecc1
fixin - initializing resources
ATorrise Sep 4, 2024
4a37668
addressing timothy's requests
ATorrise Sep 19, 2024
36a19ca
Merge remote-tracking branch 'origin/next' into system-test-cleanup
ATorrise Sep 19, 2024
5e40b67
Merge branch 'master' of https://github.com/zowe/zowe-cli into system…
ATorrise Sep 19, 2024
2d1c9be
fixing runCliScrip import and TestEnvironment.cleanup
ATorrise Sep 19, 2024
d89d3b1
createSession() to createZosmfSession()
ATorrise Sep 19, 2024
ae20141
createsession to createzosmfsession
ATorrise Sep 19, 2024
54e8d99
adding import back into test
ATorrise Sep 20, 2024
9de05a2
getting things deleted
ATorrise Sep 20, 2024
f9f3b16
Merge branch 'master' of https://github.com/zowe/zowe-cli into system…
zFernand0 Sep 26, 2024
3b008cb
review: update a few files based on comments :yum:
zFernand0 Sep 27, 2024
4a96709
chore: address Zos limitation on dataset name length
zFernand0 Sep 27, 2024
04b92c8
midway through editing file to utilize testResources
ATorrise Sep 30, 2024
5f1d974
midway changes.. tests failing
ATorrise Oct 1, 2024
6a1dc9f
test fixin
ATorrise Oct 2, 2024
a628144
1 error left in download test
ATorrise Oct 3, 2024
7f50352
Fix remaining uss download system tests
t1m0thyj Oct 3, 2024
66f5e11
Clean up resources in download system tests
t1m0thyj Oct 7, 2024
73e9201
Clean up remaining resources for zosfiles
t1m0thyj Oct 8, 2024
0a32123
Revert changes to cli-test-utils package
t1m0thyj Oct 8, 2024
e3805fd
Clean up local files from vsam tests
t1m0thyj Oct 8, 2024
b2a3bac
Fix failing zosjobs system tests
t1m0thyj Oct 11, 2024
336d3e4
Fix remaining errors in system tests
t1m0thyj Oct 14, 2024
7068b6c
Address unused variables found by CodeQL
t1m0thyj Oct 14, 2024
a2cb59e
Merge branch 'master' into system-test-cleanup
t1m0thyj Oct 14, 2024
f7f6696
Fix system tests for cancel and search jobs
t1m0thyj Oct 14, 2024
8229c76
Merge branch 'master' into system-test-cleanup
t1m0thyj Oct 18, 2024
cacdd3a
Fix failing TSO system tests
t1m0thyj Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion __tests__/__packages__/cli-test-utils/src/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,38 @@
*/

import * as fs from "fs";
import { spawnSync, SpawnSyncReturns, ExecFileException } from "child_process";
import { spawnSync, SpawnSyncReturns, ExecFileException, execSync } from "child_process";
import { ITestEnvironment } from "./environment/doc/response/ITestEnvironment";
import { CommandProfiles, ICommandDefinition, IHandlerParameters } from "@zowe/imperative";

/**
* Delete a uss file from the mainframe
* @param {string} filePath - The USS path to the file
*/
export function deleteFiles(filePath: string): void {
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
}
execSync(`zowe zos-files delete uss-file "${filePath}" -f`);
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

}

/**
* Delete a job by job ID
* @param {string} jobId - The ID of the job
*/
export function deleteJob(jobId: string): void {
execSync(`zowe zos-jobs delete job ${jobId}`);
Fixed Show fixed Hide fixed
}

/**
* Delete a dataset by name
* @param {string} datasetName - The name of the dataset
*/
export function deleteDataset(datasetName: string): void {
execSync(`zowe zos-files delete data-set "${datasetName}" -f`);
Fixed Show fixed Hide fixed
}

/**
* Execute a CLI script
* @export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@

import * as fs from "fs";
import * as nodePath from "path";

import * as yaml from "js-yaml";
import { v4 as uuidv4 } from "uuid";
import { ImperativeError, ImperativeExpect, IO, Logger, LoggingConfigurer, TextUtils } from "@zowe/imperative";

import { ISetupEnvironmentParms } from "./doc/parms/ISetupEnvironmentParms";
import { ITestEnvironment } from "./doc/response/ITestEnvironment";
import { TempTestProfiles } from "./TempTestProfiles";
import { PROJECT_ROOT_DIR, TEST_RESOURCE_DIR, TEST_RESULT_DATA_DIR, TEST_USING_WORKSPACE } from "../TestConstants";
import { runCliScript } from "../TestUtils";
import { runCliScript, deleteFiles, deleteJob, deleteDataset } from "../TestUtils";

/**
* Use the utility methods here to setup the test environment for running APIs
Expand Down Expand Up @@ -66,7 +64,12 @@ export class TestEnvironment {
const result: ITestEnvironment<any> = {
workingDir: testDirectory,
systemTestProperties: systemProps,
env
env,
resources: {
files: [],
jobs: [],
datasets: []
}
};

if (params.installPlugin) {
Expand Down Expand Up @@ -102,6 +105,17 @@ export class TestEnvironment {
const pluginDir = testEnvironment.workingDir + "/plugins";
require("rimraf").sync(pluginDir);
}

// Clean up resources
for (const file of testEnvironment.resources.files) {
deleteFiles(file);
}
for (const job of testEnvironment.resources.jobs) {
deleteJob(job);
}
for (const dataset of testEnvironment.resources.datasets) {
deleteDataset(dataset);
}
ATorrise marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
* @interface ITestEnvironment
*/
export interface ITestEnvironment<TestPropertiesSchema> {
resources: {
ATorrise marked this conversation as resolved.
Show resolved Hide resolved
files: string[];
jobs: string[];
datasets: string[];
};
/**
* The working directory for your test environment. It is a unique (uuid) area where your tests can create
* their home folders (for imperative, etc.) and you can use the area as scratch for any files, etc. that
Expand Down
Loading