Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into error-msg-help-version
Browse files Browse the repository at this point in the history
  • Loading branch information
ATorrise committed Oct 22, 2024
2 parents 1d51d5d + 027d9cc commit 150cd03
Show file tree
Hide file tree
Showing 168 changed files with 3,793 additions and 3,518 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/secrets-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ jobs:
npm run build -- --target i686-pc-windows-msvc
npm run test
target: i686-pc-windows-msvc
- host: ubuntu-latest
- host: ubuntu-22.04
target: x86_64-unknown-linux-gnu
use-cross: true
build: |
set -e
CARGO=cross npm run build -- --target x86_64-unknown-linux-gnu
- host: ubuntu-latest
- host: ubuntu-22.04
target: i686-unknown-linux-gnu
use-cross: true
build: |
set -e
source scripts/configure-cross.sh i686-unknown-linux-gnu
CARGO=cross npm run build -- --target i686-unknown-linux-gnu
- host: ubuntu-latest
- host: ubuntu-22.04
target: armv7-unknown-linux-gnueabihf
use-cross: true
build: |
set -e
source scripts/configure-cross.sh armv7-unknown-linux-gnueabihf
CARGO=cross npm run build -- --target armv7-unknown-linux-gnueabihf
- host: ubuntu-latest
- host: ubuntu-22.04
target: x86_64-unknown-linux-musl
use-cross: true
build: |
Expand All @@ -67,14 +67,14 @@ jobs:
- host: macos-latest
target: aarch64-apple-darwin
build: npm run build -- --target aarch64-apple-darwin
- host: ubuntu-latest
- host: ubuntu-22.04
target: aarch64-unknown-linux-gnu
use-cross: true
build: |
set -e
source scripts/configure-cross.sh aarch64-unknown-linux-gnu
CARGO=cross npm run build -- --target aarch64-unknown-linux-gnu
- host: ubuntu-latest
- host: ubuntu-22.04
target: aarch64-unknown-linux-musl
use-cross: true
build: |
Expand Down Expand Up @@ -208,17 +208,17 @@ jobs:
- host: macos-latest
target: x86_64-apple-darwin
architecture: x64
- host: ubuntu-latest
- host: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- host: ubuntu-latest
- host: ubuntu-22.04
target: x86_64-unknown-linux-musl
- host: ubuntu-latest
- host: ubuntu-22.04
target: aarch64-unknown-linux-gnu
platform: linux/arm64
- host: ubuntu-latest
- host: ubuntu-22.04
target: aarch64-unknown-linux-musl
platform: linux/arm64
- host: ubuntu-latest
- host: ubuntu-22.04
target: armv7-unknown-linux-gnueabihf
platform: linux/arm/v7
node:
Expand Down Expand Up @@ -250,10 +250,10 @@ jobs:
if: ${{ matrix.settings.platform }}
- name: Test bindings
run: npm run test
if: ${{ matrix.settings.host != 'ubuntu-latest' }}
if: ${{ matrix.settings.host != 'ubuntu-22.04' }}
- name: Setup and run tests
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.host == 'ubuntu-latest' && !endsWith(matrix.settings.target, 'musl') }}
if: ${{ matrix.settings.host == 'ubuntu-22.04' && !endsWith(matrix.settings.target, 'musl') }}
with:
image: ${{ format('node:{0}-slim', matrix.node) }}
options: "-v ${{ github.workspace }}:/build -w /build --cap-add=IPC_LOCK ${{ matrix.settings.platform && format('--platform={0}', matrix.settings.platform) }}"
Expand All @@ -263,7 +263,7 @@ jobs:
cd packages/secrets && dbus-run-session -- bash scripts/linux-test.sh
- name: Setup and run tests (MUSL)
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.host == 'ubuntu-latest' && endsWith(matrix.settings.target, 'musl') }}
if: ${{ matrix.settings.host == 'ubuntu-22.04' && endsWith(matrix.settings.target, 'musl') }}
with:
image: ${{ format('node:{0}-alpine', matrix.node) }}
options: "-v ${{ github.workspace }}:/build -w /build --cap-add=IPC_LOCK ${{ matrix.settings.platform && format('--platform={0}', matrix.settings.platform) }}"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/zowe-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
node-version: [18.x, 20.x]
os:
- windows-latest
- ubuntu-latest
- ubuntu-22.04
- ${{ github.event.inputs.macos-type || 'macos-14'}}

env:
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:

- name: Unlock Keyring
id: unlock-keyring
if: ${{ always() && steps.build.outcome == 'success' && matrix.os == 'ubuntu-latest' }}
if: ${{ always() && steps.build.outcome == 'success' && matrix.os == 'ubuntu-22.04' }}
uses: t1m0thyj/unlock-keyring@v1

- name: Start Daemon
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
release:
if: github.event_name == 'push' && github.ref_protected
needs: test
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
issues: write
contents: write
Expand Down
4 changes: 2 additions & 2 deletions __tests__/__packages__/cli-test-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zowe/cli-test-utils",
"version": "8.1.1",
"version": "8.2.0",
"description": "Test utilities package for Zowe CLI plug-ins",
"author": "Zowe",
"license": "EPL-2.0",
Expand Down Expand Up @@ -43,7 +43,7 @@
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/uuid": "^10.0.0",
"@zowe/imperative": "8.1.0"
"@zowe/imperative": "8.2.0"
},
"peerDependencies": {
"@zowe/imperative": "^8.0.0"
Expand Down
92 changes: 84 additions & 8 deletions __tests__/__src__/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,83 @@
*/

import { randomBytes } from "crypto";
import { ZosFilesConstants } from "../../packages/zosfiles/src";
import * as fs from "fs";
import { Imperative, Headers, AbstractSession } from "@zowe/imperative";
import { ZosmfRestClient } from "../../packages/core/src";
import { ZosFilesConstants, Delete } from "../../packages/zosfiles/src";
import { DeleteJobs, GetJobs, ICommonJobParms, IDeleteJobParms, IJob } from "../../packages/zosjobs/src";
import { promisify } from "util";

/**
* Delete a local testing file after use
* @param {string} filePath - File path of temporary file
*/
export function deleteLocalFile(filePath: string): void {
try {
fs.unlinkSync(filePath);
} catch {
throw new Error(`Error deleting local file: ${filePath}`);
}
}

/**
* Delete local directories after use
* @param {string[]} directories - Array of directories to delete
*/
export function deleteLocalDirectories(directories: string[]): void {
directories.forEach((dir) => {
try {
if (fs.existsSync(dir)) {
fs.rmdirSync(dir, { recursive: true });
}
} catch {
throw new Error(`Error deleting directory: ${dir}`);
}
});
}

/**
* Deletes a USS file from the mainframe
* @param {AbstractSession} session - The session object
* @param {string} fileName - The name of the file to delete
* @returns {Promise<void>} A promise that resolves when the file is deleted
*/
export async function deleteFiles(session: AbstractSession, fileName: string): Promise<void> {
await Delete.ussFile(session, fileName, true); //recursive = true
}

/**
* Deletes a data set from the mainframe
* @param {AbstractSession} session - The session object
* @param {string} dataSetName - The name of the data set to delete.
* @returns {Promise<void>} A promise that resolves when the data set is deleted
*/
export async function deleteDataset(session: AbstractSession, dataSetName: string): Promise<void> {
await Delete.dataSet(session, dataSetName);
}

/**
* Delete a job from the mainframe using Zowe SDKs - IJob
* @param {AbstractSession} session - z/OSMF connection info
* @param {IJob | string} job - the job or job ID that you want to delete
* @returns {Promise<void>} A promise that resolves when the job is deleted.
*/
export async function deleteJob(session: AbstractSession, job: IJob | string): Promise<void> {
if (typeof job === "string") {
job = await GetJobs.getJob(session, job);
}
await DeleteJobs.deleteJobForJob(session, job);
}

/**
* Delete a job from the mainframe using Zowe SDKs - jobid, jobname
* @param {AbstractSession} session - z/OSMF connection info
* @param {params} ICommonJobParms - constains jobname and jobid for job to delete
* @returns {Promise<void>} A promise that resolves when the job is deleted.
*/
export async function deleteJobCommon(session: AbstractSession, params: ICommonJobParms): Promise<void> {
await DeleteJobs.deleteJobCommon(session, params as IDeleteJobParms);
}

/**
* This function strips any new lines out of the string passed.
Expand All @@ -32,14 +106,14 @@ export function stripNewLines(str: string): string {
* @param {string} hlq User specified high level qualify
* @returns {string} A generated data set name
*/
export function getUniqueDatasetName(hlq: string, encoded = false): string {
export function getUniqueDatasetName(hlq: string, encoded = false, maxNodes = 2): string {
let generatedName: string = "";
const randomNumber = Math.random();
const timestampInMsNum = Date.now();
let timestampInMs = Math.floor(randomNumber * timestampInMsNum).toString();
let tempStr: string;
const MAX_NODE_LENGTH = 7;
let MAX_NODES = 2;
let MAX_NODES = maxNodes;
let currNodes = 0;

if (encoded) {MAX_NODES = 1;}
Expand Down Expand Up @@ -100,11 +174,13 @@ export async function getTag(session: AbstractSession, ussPath: string) {
return response.stdout[0];
}

export function delay(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms) );
}

export const delTime = 500;
/**
* Pauses execution for a given number of milliseconds.
* @param {number} ms - Number of milliseconds to wait
* @returns {Promise<void>} - Resolves after the specified time has passed
*/
export const wait = promisify(setTimeout);
export const waitTime = 2000; //wait 2 seconds

/**
* Use instead of `util.inspect` to get consistently formatted output that can be used in snapshots.
Expand Down
27 changes: 27 additions & 0 deletions __tests__/__src__/environment/ITestEnvironment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

import { ITestEnvironment as IBaseTestEnvironment } from "../../__packages__/cli-test-utils/src/environment/doc/response/ITestEnvironment";
import { ITestEnvironmentResources } from "./ITestEnvironmentResources";

/**
* The test environment for your test.
* @export
* @interface ITestEnvironment
*/
export interface ITestEnvironment<TestPropertiesSchema> extends IBaseTestEnvironment<TestPropertiesSchema>{
/**
* A collection of resources used within the test environment that need to be cleaned up once test finishes.
* @type {ITestEnvironmentResources}
* @memberof ITestEnvironment
*/
resources?: ITestEnvironmentResources;
}
50 changes: 50 additions & 0 deletions __tests__/__src__/environment/ITestEnvironmentResources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

import { AbstractSession } from "@zowe/imperative";
import { IJob } from "../../../packages/zosjobs";

/**
* Represents the resources used within the test environment.
* @export
* @interface ITestEnvironmentResources
*/
export interface ITestEnvironmentResources {
/**
* Array of local file paths used within the test environment.
* @type {string[]}
*/
localFiles: string[];

/**
* Array of mainframe uss files used within the test environment.
* @type {string[]}
*/
files: string[];

/**
* Array of job objects or job IDs representing jobs submitted to the mainframe during the test.
* @type {IJob[]}
*/
jobs: (IJob | string)[];

/**
* Array of dataset names used within the test environment.
* @type {string[]}
*/
datasets: string[];

/**
* The session used for interacting with z/OS systems during the test, if applicable.
* @type {AbstractSession}
*/
session?: AbstractSession;
}
Loading

0 comments on commit 150cd03

Please sign in to comment.