Skip to content

Commit

Permalink
system test work
Browse files Browse the repository at this point in the history
Signed-off-by: jace-roell <jace.roell@hotmail.com>
  • Loading branch information
jace-roell committed Nov 1, 2024
1 parent 2483f41 commit 1f57ce6
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 4 deletions.
1 change: 1 addition & 0 deletions ENCO#EDJR897694.ZOSFILE.DOWNLOAD.A73312.ENCO#ED
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$)$)$)
1 change: 1 addition & 0 deletions JR897694.ZOSFILE.DOWNLOAD.A1562310.A442242
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$)$)$)
1 change: 1 addition & 0 deletions JR897694.ZOSFILE.DOWNLOAD.A2353578.A5866
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$)$)$)
1 change: 1 addition & 0 deletions JR897694.ZOSFILE.DOWNLOAD.A6003736.A78861
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abcdefghijklmnopqrstuvwxyz
1 change: 1 addition & 0 deletions JR897694.ZOSFILE.DOWNLOAD.A8747183.A70397
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$)$)$)
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
*.bin binary binary
*.jcl IBM-1047 IBM-1047
*.md UTF-8 UTF-8
*.txt UTF-8 IBM-1147
*.txt binary binary
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
IMountFsOptions,
Mount,
Unmount,
IUSSListOptions
IUSSListOptions,
ZosFilesAttributes
} from "../../../../src";
import { Imperative, IO, Session } from "@zowe/imperative";
import { inspect } from "util";
Expand All @@ -37,10 +38,12 @@ import { posix } from "path";
import { Shell } from "@zowe/zos-uss-for-zowe-sdk";
import { PassThrough } from "stream";
import { text } from "stream/consumers";
import { runCliScript } from "../../../../../../__tests__/__packages__/cli-test-utils/lib";

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import runCliScript.

const rimraf = require("rimraf").sync;
const delayTime = 2000;
const testData = "abcdefghijklmnopqrstuvwxyz";
const testDataBinary = "[][][]";

let REAL_SESSION: Session;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
Expand Down Expand Up @@ -1018,7 +1021,7 @@ describe.each([false, true])("Download Data Set - Encoded: %s", (encoded: boolea
let error;
let response: IZosFilesResponse;

await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData));
await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testDataBinary));
await wait(delayTime);

try {
Expand Down Expand Up @@ -1081,6 +1084,61 @@ describe.each([false, true])("Download Data Set - Encoded: %s", (encoded: boolea

});

it("should download uss file with --attributes flag", async () => {
let error;
let response: any;
let downloadResponse: any;
let zosAttributes = Object.create(ZosFilesAttributes.prototype);
zosAttributes.attributes = new Map([
['*.json', { ignore: true }],
['*.bin', { ignore: false, localEncoding: 'binary', remoteEncoding: 'binary' }],
['*.jcl', { ignore: false, localEncoding: 'IBM-1047', remoteEncoding: 'IBM-1047' }],
['*.md', { ignore: false, localEncoding: 'UTF-8', remoteEncoding: 'UTF-8' }],
['*.txt', { ignore: false, localEncoding: 'UTF-8', remoteEncoding: 'IBM-1047' }]
]);
try {
response = await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testDataBinary));
downloadResponse = await Download.ussFile(REAL_SESSION, ussname, { attributes: zosAttributes});
} catch (err) {
error = err;
}
expect(error).toBeFalsy();
expect(response).toBeTruthy();
expect(downloadResponse).toBeTruthy();

// Compare the downloaded contents to those uploaded
const fileContents = stripNewLines(fs.readFileSync(`./${posix.basename(ussname)}`).toString());
expect(fileContents).toEqual(testDataBinary);
});

it("should download uss file with --attributes flag - binary", async () => {
let error;
let response: any;
let downloadResponse: any;
let zosAttributes = Object.create(ZosFilesAttributes.prototype);
zosAttributes.attributes = new Map([
['*.json', { ignore: true }],
['*.bin', { ignore: false, localEncoding: 'binary', remoteEncoding: 'binary' }],
['*.jcl', { ignore: false, localEncoding: 'IBM-1047', remoteEncoding: 'IBM-1047' }],
['*.md', { ignore: false, localEncoding: 'UTF-8', remoteEncoding: 'UTF-8' }],
['*.txt', { ignore: false, localEncoding: 'binary', remoteEncoding: 'binary' }]
]);
try {
response = await Upload.uploadFile(REAL_SESSION, __dirname+"/__resources__/testfiles/downloadEncodingCheck.txt" ,ussname, { attributes: zosAttributes});
downloadResponse = await Download.ussFile(REAL_SESSION, ussname, { attributes: zosAttributes});
} catch (err) {
error = err;
}
expect(error).toBeFalsy();
expect(response).toBeTruthy();
expect(downloadResponse).toBeTruthy();

// Compare the downloaded contents to those uploaded
const fileContents = stripNewLines(fs.readFileSync(`./${posix.basename(ussname)}`).toString());

expect(fileContents).toEqual(fs.readFileSync(__dirname+"/__resources__/testfiles/downloadEncodingCheck.txt").toString());
});

// When requesting etag, z/OSMF has a limit on file size when it stops to return etag by default (>8mb)
// We are passing X-IBM-Return-Etag to force z/OSMF to always return etag, but testing here for case where it would be optional
it("should download a 10mb uss file and return Etag", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.json -
*.bin binary binary
*.jcl IBM-1047 IBM-1047
*.md UTF-8 UTF-8
*.txt UTF-8 IBM-1047
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.json -
*.bin binary binary
*.jcl IBM-1047 IBM-1047
*.md UTF-8 UTF-8
*.txt binary binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
account=$1
host=$2
port=$3
user=$4
password=$5
ru=$6
fileToDownload=$7
attributes=$8

zowe zos-files download uss $fileToDownload --attributes $attributes --host $host --port $port --user $user --password $password --ru $ru
exit $?
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[][][]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
account=$1
host=$2
port=$3
user=$4
password=$5
ru=$6
inputFile=$7
ussName=$8
encoding=$9

zowe zos-files upload file-to-uss $inputFile $ussName --encoding $encoding --host $host --port $port --user $user --password $password --ru $ru
exit $?
1 change: 0 additions & 1 deletion usstest.txt

This file was deleted.

0 comments on commit 1f57ce6

Please sign in to comment.