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

Extended acceptance tests AWS (#233) #234

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
node_modules
.nyc_output/
coverage/
/controller/aws*.sh
testmerge.json
.env.local*
.env.development.local*
Expand Down
1 change: 1 addition & 0 deletions common/src/s3file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class PpaasS3File implements S3File {
this.contentType = "text/x-yaml";
break;
case ".json":
case ".info":
this.contentType = "application/json";
break;
default:
Expand Down
10 changes: 9 additions & 1 deletion controller/acceptance/errorFile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ACCEPTANCE_AWS_PERMISSIONS, integrationUrl, uploadAcceptanceFiles } from "./util";
import { API_ERROR, API_SEARCH, API_TEST, TestData } from "../types";
import { LogLevel, PpaasTestId, TestStatus, log } from "@fs/ppaas-common";
import _axios, { AxiosRequestConfig, AxiosResponse as Response } from "axios";
import { getPpaasTestId, getTestData, integrationUrl } from "./test.spec";
import { getPpaasTestId, getTestData } from "./test.spec";
import { expect } from "chai";

const REDIRECT_TO_S3: boolean = process.env.REDIRECT_TO_S3 === "true";
Expand Down Expand Up @@ -36,6 +37,12 @@ describe("ErrorFile API Integration", function () {
this.timeout(60000);
url = integrationUrl + API_ERROR;
log("ErrorFile tests url=" + url, LogLevel.DEBUG);
if (ACCEPTANCE_AWS_PERMISSIONS) {
const { ppaasTestId } = await uploadAcceptanceFiles();
yamlFile = ppaasTestId.yamlFile;
dateString = ppaasTestId.dateString;
expectedStatus = 200;
} else {
// Initialize to one that will 404 for the build server
const ppaasTestId = await getPpaasTestId();
yamlFile = ppaasTestId.yamlFile;
Expand Down Expand Up @@ -87,6 +94,7 @@ describe("ErrorFile API Integration", function () {
} catch (error) {
log("Could not Search and find Results", LogLevel.ERROR, error);
}
} // end else not ACCEPTANCE_AWS_PERMISSIONS
});

it("GET /error should respond 404 Not Found", (done: Mocha.Done) => {
Expand Down
4 changes: 1 addition & 3 deletions controller/acceptance/healthcheck.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { API_HEALTHCHECK, API_HEALTHCHECK_HEARTBEAT, API_HEALTHCHECK_S3, API_HEA
import { LogLevel, log } from "@fs/ppaas-common";
import _axios, { AxiosResponse as Response } from "axios";
import { expect } from "chai";
import { integrationUrl } from "./util";

const fetch = _axios.get;

// Beanstalk <SYSTEM_NAME>_<SERVICE_NAME>_URL
const integrationUrl = "http://" + (process.env.BUILD_APP_URL || `localhost:${process.env.PORT || "8081"}`);

describe("Healthcheck Integration", () => {
let url: string;

Expand Down
4 changes: 1 addition & 3 deletions controller/acceptance/pewpew.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import _axios, { AxiosRequestConfig, AxiosResponse as Response } from "axios";
import FormData from "form-data";
import { createReadStream } from "fs";
import { expect } from "chai";
import { integrationUrl } from "./util";
import { latestPewPewVersion } from "../pages/api/util/clientutil";
import path from "path";
import semver from "semver";
Expand All @@ -38,9 +39,6 @@ async function fetch (
const UNIT_TEST_FOLDER = process.env.UNIT_TEST_FOLDER || "test";
const PEWPEW_ZIP_FILEPATH = process.env.PEWPEW_ZIP_FILEPATH || path.join(UNIT_TEST_FOLDER, PEWPEW_BINARY_EXECUTABLE + ".zip");

// Beanstalk <SYSTEM_NAME>_<SERVICE_NAME>_URL
const integrationUrl = "http://" + (process.env.BUILD_APP_URL || `localhost:${process.env.PORT || "8081"}`);

let sharedPewPewVersions: string[] | undefined;
let uploadedPewPewVersion: string | undefined;

Expand Down
4 changes: 1 addition & 3 deletions controller/acceptance/queues.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import {
import { AgentQueueDescription, LogLevel, log } from "@fs/ppaas-common";
import _axios, { AxiosResponse as Response } from "axios";
import { expect } from "chai";
import { integrationUrl } from "./util";

const fetch = _axios.get;

// Beanstalk <SYSTEM_NAME>_<SERVICE_NAME>_URL
const integrationUrl = "http://" + (process.env.BUILD_APP_URL || `localhost:${process.env.PORT || "8081"}`);

let sharedQueueNames: string[] | undefined;

export async function getQueueNames (): Promise<string[]> {
Expand Down
15 changes: 12 additions & 3 deletions controller/acceptance/resultsFile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ACCEPTANCE_AWS_PERMISSIONS, integrationUrl, uploadAcceptanceFiles } from "./util";
import { API_JSON, API_SEARCH, API_TEST, TestData } from "../types";
import { LogLevel, PpaasTestId, TestStatus, log } from "@fs/ppaas-common";
import _axios, { AxiosRequestConfig, AxiosResponse as Response } from "axios";
import { getPpaasTestId, getTestData, integrationUrl } from "./test.spec";
import { getPpaasTestId, getTestData } from "./test.spec";
import { expect } from "chai";

const REDIRECT_TO_S3: boolean = process.env.REDIRECT_TO_S3 === "true";
Expand Down Expand Up @@ -36,6 +37,13 @@ describe("ResultsFile API Integration", function () {
this.timeout(60000);
url = integrationUrl + API_JSON;
log("ResultsFile tests url=" + url, LogLevel.DEBUG);
if (ACCEPTANCE_AWS_PERMISSIONS) {
const { ppaasTestId, resultsFile: resultsFileName } = await uploadAcceptanceFiles();
yamlFile = ppaasTestId.yamlFile;
dateString = ppaasTestId.dateString;
resultsFile = resultsFileName;
} else {
// Initialize to one that will 404 for the build server
const ppaasTestId = await getPpaasTestId();
yamlFile = ppaasTestId.yamlFile;
dateString = ppaasTestId.dateString;
Expand Down Expand Up @@ -97,7 +105,8 @@ describe("ResultsFile API Integration", function () {
} catch (error) {
log("Could not Search and find Results", LogLevel.ERROR, error);
}
});
} // end else not ACCEPTANCE_AWS_PERMISSIONS
});

it("GET json should respond 404 Not Found", (done: Mocha.Done) => {
fetch(url).then((res: Response) => {
Expand Down Expand Up @@ -179,7 +188,7 @@ describe("ResultsFile API Integration", function () {
log(`GET ${url}/${yamlFile}/${dateString}/${resultsFile}`, LogLevel.DEBUG, { res });
expect(res, "res").to.not.equal(undefined);
// The build server will 404 because there won't be any completed tests, localhost should have some
if (url.includes("localhost")) {
if (url.includes("localhost") || ACCEPTANCE_AWS_PERMISSIONS) {
log(`GET ${url}/${yamlFile}/${dateString}/${resultsFile}`, LogLevel.DEBUG, { data: res.data });
if (REDIRECT_TO_S3) {
expect(res.status, "status").to.equal(302);
Expand Down
3 changes: 2 additions & 1 deletion controller/acceptance/schedule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import {
TestData,
TestManagerError
} from "../types";
import { BASIC_FILEPATH, getScheduledTestData, integrationUrl, unsetScheduledTestData } from "./test.spec";
import { BASIC_FILEPATH, getScheduledTestData, unsetScheduledTestData } from "./test.spec";
import { LogLevel, TestStatus, log } from "@fs/ppaas-common";
import _axios, { AxiosRequestConfig, AxiosResponse as Response } from "axios";
import { EventInput } from "@fullcalendar/core";
import { expect } from "chai";
import { getQueueNames } from "./queues.spec";
import { integrationUrl } from "./util";
import path from "path";

async function fetch (
Expand Down
13 changes: 10 additions & 3 deletions controller/acceptance/search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ACCEPTANCE_AWS_PERMISSIONS, integrationUrl, uploadAcceptanceFiles } from "./util";
import { API_SEARCH, API_TEST_STATUS, TestData, TestManagerMessage } from "../types";
import { LogLevel, PpaasTestId, TestStatus, log } from "@fs/ppaas-common";
import _axios, { AxiosRequestConfig, AxiosResponse as Response } from "axios";
import { getTestData, integrationUrl } from "./test.spec";
import { expect } from "chai";
import { getTestData } from "./test.spec";

async function fetch (
url: string,
Expand Down Expand Up @@ -62,8 +63,14 @@ describe("Search API Integration", () => {
before(async () => {
url = integrationUrl + API_SEARCH;
log("search tests url=" + url, LogLevel.DEBUG);
const testData = await getTestData();
s3Folder = testData.s3Folder;
if (ACCEPTANCE_AWS_PERMISSIONS) {
// Populate a finished result
const { ppaasTestId } = await uploadAcceptanceFiles();
s3Folder = ppaasTestId.s3Folder;
} else {
const testData = await getTestData();
s3Folder = testData.s3Folder;
}
});

describe("GET /search", () => {
Expand Down
3 changes: 2 additions & 1 deletion controller/acceptance/stop.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { API_STOP, TestManagerMessage } from "../types";
import { LogLevel, PpaasTestId, log } from "@fs/ppaas-common";
import _axios, { AxiosRequestConfig, AxiosResponse as Response } from "axios";
import { getPpaasTestId, integrationUrl } from "./test.spec";
import { expect } from "chai";
import { getPpaasTestId } from "./test.spec";
import { integrationUrl } from "./util";

async function fetch (
url: string,
Expand Down
12 changes: 5 additions & 7 deletions controller/acceptance/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { createReadStream } from "fs";
import { expect } from "chai";
import { getPewPewVersions } from "./pewpew.spec";
import { getQueueNames } from "./queues.spec";
import { integrationUrl } from "./util";
import { latestPewPewVersion } from "../pages/api/util/clientutil";
import path from "path";

Expand Down Expand Up @@ -63,13 +64,6 @@ const defaultEnvironmentVariables: EnvironmentVariablesFile = {
TEST2: "true"
};

// Beanstalk <SYSTEM_NAME>_<SERVICE_NAME>_URL
export const integrationUrl = "http://" + (process.env.BUILD_APP_URL || `localhost:${process.env.PORT || "8081"}`);

let sharedPpaasTestId: PpaasTestId | undefined;
let sharedTestData: TestData | undefined;
let sharedScheduledTestData: TestData | undefined;

function appendFileData (formData: FormData, formName: string, fileData: string | FileData) {
if (typeof fileData === "string") {
formData.append(formName, fileData);
Expand Down Expand Up @@ -122,6 +116,10 @@ function convertFormDataPutToFormData (formDataPut: FormDataPut): FormData {
return formData;
}

let sharedPpaasTestId: PpaasTestId | undefined;
let sharedTestData: TestData | undefined;
let sharedScheduledTestData: TestData | undefined;

export async function getPpaasTestId (): Promise<PpaasTestId> {
if (sharedPpaasTestId) { return sharedPpaasTestId; }
await initSharedTestData();
Expand Down
7 changes: 7 additions & 0 deletions controller/acceptance/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export { uploadAcceptanceFiles } from "../integration/util";

// Shared functions for Acceptance Tests
export const ACCEPTANCE_AWS_PERMISSIONS: boolean = process.env.ACCEPTANCE_AWS_PERMISSIONS?.toLowerCase() === "true";

// Beanstalk <SYSTEM_NAME>_<SERVICE_NAME>_URL
export const integrationUrl = "http://" + (process.env.BUILD_APP_URL || `localhost:${process.env.PORT || "8081"}`);
3 changes: 2 additions & 1 deletion controller/acceptance/yamlFile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { BASIC_FILEPATH, getPpaasTestId, integrationUrl } from "./test.spec";
import { BASIC_FILEPATH, getPpaasTestId } from "./test.spec";
import { LogLevel, PpaasTestId, log } from "@fs/ppaas-common";
import _axios, { AxiosRequestConfig, AxiosResponse as Response } from "axios";
import { API_YAML } from "../types";
import { expect } from "chai";
import { integrationUrl } from "./util";
import path from "path";

const REDIRECT_TO_S3: boolean = process.env.REDIRECT_TO_S3 === "true";
Expand Down
Loading