Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into EVG-18598
Browse files Browse the repository at this point in the history
  • Loading branch information
khelif96 committed Sep 27, 2023
2 parents 6c3393c + 62a296c commit 9ab1c42
Show file tree
Hide file tree
Showing 203 changed files with 3,283 additions and 1,727 deletions.
62 changes: 55 additions & 7 deletions cypress/integration/distroSettings/host_section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ describe("host section", () => {
cy.dataCy("future-fraction-input").should("not.exist");
});

it("errors when selecting an incompatible host communication method", () => {
it("shows an error when selecting an incompatible host communication method", () => {
cy.selectLGOption("Host Communication Method", "RPC");
save();
cy.validateToast(
"error",
"validating changes for distro 'localhost': 'ERROR: bootstrapping hosts using legacy SSH is incompatible with non-legacy host communication'"
cy.contains(
"Legacy and non-legacy bootstrapping and communication are incompatible."
);
cy.selectLGOption("Host Communication Method", "Legacy SSH");
});

it("updates host fields", () => {
Expand All @@ -40,7 +37,7 @@ describe("host section", () => {
);

save();
cy.validateToast("success");
cy.validateToast("success", "Updated distro.");

// Reset fields
cy.selectLGOption("Agent Architecture", "Linux 64-bit");
Expand All @@ -53,6 +50,57 @@ describe("host section", () => {
cy.selectLGOption("Host Allocator Feedback Rule", "Default");
cy.selectLGOption("Host Overallocation Rule", "Default");

save();
cy.validateToast("success", "Updated distro.");
});
});

describe("using User Data bootstrap method", () => {
beforeEach(() => {
cy.visit("/distro/ubuntu1604-parent/settings/host");
cy.selectLGOption("Host Bootstrap Method", "User Data");
cy.selectLGOption("Host Communication Method", "RPC");
});

it("shows Windows-only fields when the architecture is updated", () => {
cy.contains("label", "Root Directory").should("not.exist");
cy.contains("label", "Service User").should("not.exist");

cy.selectLGOption("Agent Architecture", "Windows 64-bit");

cy.getInputByLabel("Root Directory").should("exist");
cy.getInputByLabel("Service User").should("exist");
});

it("hides resource limit fields when the architecture is not Linux", () => {
cy.contains("Resource Limits").should("exist");
cy.selectLGOption("Agent Architecture", "Windows 64-bit");
cy.contains("Resource Limits").should("not.exist");
});

it("saves bootstrap settings", () => {
cy.getInputByLabel("Jasper Binary Directory").type("/jasper/binary");
cy.getInputByLabel("Jasper Credentials Path").type("/jasper/credentials");
cy.getInputByLabel("Client Directory").type("/client/dir");
cy.getInputByLabel("Shell Path").type("/shell/path");
cy.getInputByLabel("Home Volume Format Command").type(
"echo 'Hello World'"
);
cy.getInputByLabel("Number of Files").type("10");
cy.getInputByLabel("Number of CGroup Tasks").type("20");
cy.getInputByLabel("Number of Processes").type("30");
cy.getInputByLabel("Locked Memory").type("128");
cy.getInputByLabel("Virtual Memory").type("256");

cy.contains("button", "Add variable").click();
cy.getInputByLabel("Key").type("my-key");
cy.getInputByLabel("Value").type("my-value");

cy.contains("button", "Add script").click();
cy.getInputByLabel(/^Path$/).type("/path/to/precondition/script");
cy.getInputByLabel(/^Script$/).type("script contents here");

cy.dataCy("save-settings-button").scrollIntoView();
save();
cy.validateToast("success");
});
Expand Down
84 changes: 83 additions & 1 deletion cypress/integration/distroSettings/provider_section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe("provider section", () => {
});
cy.contains("button", "Add security group").click();
cy.getInputByLabel("Security Group ID").type("group-1234");
cy.contains("button", "Add host").click();
cy.getInputByLabel("Name").type("host-1234");
save();
cy.validateToast("success");

Expand All @@ -27,7 +29,8 @@ describe("provider section", () => {
cy.getInputByLabel("Merge with existing user data").uncheck({
force: true,
});
cy.dataCy("delete-item-button").click();
cy.dataCy("delete-item-button").first().click();
cy.dataCy("delete-item-button").first().click();
save();
cy.validateToast("success");
});
Expand Down Expand Up @@ -83,4 +86,83 @@ describe("provider section", () => {
cy.validateToast("success");
});
});

describe("ec2 fleet", () => {
beforeEach(() => {
cy.visit("/distro/ubuntu1804-workstation/settings/provider");
});

it("shows and hides fields correctly", () => {
// Fleet options.
cy.getInputByLabel("Fleet Instance Type").contains("On-demand");
cy.contains("Capacity optimization").should("not.exist");

cy.selectLGOption("Fleet Instance Type", "Spot");
cy.contains("Capacity optimization").should("exist");

// VPC options.
cy.dataCy("use-vpc").should("be.checked");
cy.contains("Default VPC Subnet ID").should("exist");
cy.contains("VPC Subnet Prefix").should("exist");

cy.dataCy("use-vpc").uncheck({ force: true });
cy.contains("Default VPC Subnet ID").should("not.exist");
cy.contains("VPC Subnet Prefix").should("not.exist");
});

it("successfully updates ec2 fleet provider fields", () => {
cy.dataCy("provider-select").contains("EC2 Fleet");

// Correct section is displayed.
cy.dataCy("ec2-fleet-provider-settings").should("exist");
cy.dataCy("region-select").contains("us-east-1");

// Change field values.
cy.selectLGOption("Region", "us-west-1");
cy.getInputByLabel("SSH Key Name").as("keyNameInput");
cy.get("@keyNameInput").clear();
cy.get("@keyNameInput").type("my ssh key");
cy.selectLGOption("Fleet Instance Type", "Spot");
cy.contains("button", "Add mount point").click();
cy.getInputByLabel("Device Name").type("device name");
cy.getInputByLabel("Size").type("200");
save();
cy.validateToast("success");

// Revert fields to original values.
cy.selectLGOption("Region", "us-east-1");
cy.get("@keyNameInput").clear();
cy.get("@keyNameInput").type("mci");
cy.selectLGOption("Fleet Instance Type", "On-demand");
cy.dataCy("mount-points").within(() => {
cy.dataCy("delete-item-button").click();
});
save();
cy.validateToast("success");
});

it("can add and delete region settings", () => {
cy.dataCy("ec2-fleet-provider-settings").should("exist");

// Add item for new region.
cy.contains("button", "Add region settings").click();
cy.contains("button", "Add region settings").should("not.exist");

// Save new region.
cy.selectLGOption("Region", "us-west-1");
cy.getInputByLabel("EC2 AMI ID").type("ami-1234");
cy.getInputByLabel("Instance Type").type("m5.xlarge");
cy.contains("button", "Add security group").click();
cy.getInputByLabel("Security Group ID").type("security-group-1234");
save();
cy.validateToast("success");

// Revert to original state by deleting the new region.
cy.dataCy("delete-item-button").first().click();
save();
cy.validateToast("success");

cy.contains("button", "Add region settings").should("exist");
});
});
});
35 changes: 29 additions & 6 deletions cypress/integration/distroSettings/task_section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,37 @@ import { save } from "./utils";

describe("task section", () => {
beforeEach(() => {
cy.visit("/distro/localhost/settings/task");
cy.visit("/distro/ubuntu1804-workstation/settings/task");
});

it("should only show tunable options if planner version is tunable", () => {
cy.getInputByLabel("Task Planner Version").should("contain.text", "Legacy");
cy.dataCy("tunable-options").should("not.exist");
cy.selectLGOption("Task Planner Version", "Tunable");
cy.dataCy("tunable-options").should("be.visible");
describe("providers", () => {
describe("static provider", () => {
it("should not show tunable options", () => {
cy.visit("/distro/localhost/settings/task");
cy.selectLGOption("Task Planner Version", "Tunable");
cy.dataCy("tunable-options").should("not.exist");
});
});

describe("docker provider", () => {
it("should not show tunable options", () => {
cy.visit("/distro/ubuntu1604-container-test/settings/task");
cy.selectLGOption("Task Planner Version", "Tunable");
cy.dataCy("tunable-options").should("not.exist");
});
});

describe("ec2 provider", () => {
it("should only show tunable options if planner version is tunable", () => {
cy.getInputByLabel("Task Planner Version").should(
"contain.text",
"Legacy"
);
cy.dataCy("tunable-options").should("not.exist");
cy.selectLGOption("Task Planner Version", "Tunable");
cy.dataCy("tunable-options").should("be.visible");
});
});
});

it("should surface warnings for invalid number inputs", () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Cypress.Commands.add("enterLoginCredentials", () => {
});

/* getInputByLabel */
Cypress.Commands.add("getInputByLabel", (label: string) => {
Cypress.Commands.add("getInputByLabel", (label: string | RegExp) => {
// LeafyGreen inputs start out with ids of "undefined". Wait until LeafyGreen components have proper ids.
cy.contains("label", label)
.should("have.attr", "for")
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ declare global {
* Custom command to enter get an input by its label
* @example cy.getInputBylabel("Some Label")
*/
getInputByLabel(label: string): Chainable<Element>;
getInputByLabel(label: string | RegExp): Chainable<Element>;
/**
* Custom command to select an option from a leafygreen select component by label
* @param label The label of the select component
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spruce",
"version": "3.0.139",
"version": "3.0.143",
"private": true,
"scripts": {
"bootstrap-logkeeper": "./scripts/bootstrap-logkeeper.sh",
Expand Down Expand Up @@ -54,17 +54,17 @@
"extends": "react-app"
},
"dependencies": {
"@apollo/client": "3.6.9",
"@apollo/client": "3.8.4",
"@bugsnag/js": "7.20.2",
"@bugsnag/plugin-react": "7.18.0",
"@emotion/css": "11.11.2",
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@leafygreen-ui/badge": "8.0.2",
"@leafygreen-ui/banner": "7.0.4",
"@leafygreen-ui/button": "21.0.0",
"@leafygreen-ui/button": "21.0.6",
"@leafygreen-ui/callout": "9.0.13",
"@leafygreen-ui/card": "9.0.1",
"@leafygreen-ui/card": "10.0.5",
"@leafygreen-ui/checkbox": "12.0.5",
"@leafygreen-ui/code": "14.0.1",
"@leafygreen-ui/combobox": "5.0.7",
Expand All @@ -77,7 +77,7 @@
"@leafygreen-ui/inline-definition": "6.0.0",
"@leafygreen-ui/interaction-ring": "7.0.2",
"@leafygreen-ui/leafygreen-provider": "3.1.0",
"@leafygreen-ui/loading-indicator": "2.0.5",
"@leafygreen-ui/loading-indicator": "2.0.6",
"@leafygreen-ui/menu": "20.0.1",
"@leafygreen-ui/modal": "16.0.1",
"@leafygreen-ui/number-input": "1.0.4",
Expand All @@ -89,7 +89,7 @@
"@leafygreen-ui/search-input": "2.0.8",
"@leafygreen-ui/segmented-control": "8.2.6",
"@leafygreen-ui/select": "10.2.0",
"@leafygreen-ui/side-nav": "13.0.2",
"@leafygreen-ui/side-nav": "14.0.3",
"@leafygreen-ui/skeleton-loader": "1.1.0",
"@leafygreen-ui/table": "10.0.1",
"@leafygreen-ui/table/new": "npm:@leafygreen-ui/[email protected]",
Expand All @@ -111,7 +111,7 @@
"date-fns-tz": "2.0.0",
"deep-object-diff": "1.1.9",
"env-cmd": "10.1.0",
"graphql": "16.6.0",
"graphql": "16.8.1",
"html-react-parser": "4.2.1",
"js-cookie": "3.0.5",
"linkify-html": "4.1.1",
Expand Down Expand Up @@ -162,7 +162,7 @@
"@types/new-relic-browser": "0.1212.2",
"@types/node": "^16.11.47",
"@types/pluralize": "0.0.29",
"@types/prompts": "2.4.4",
"@types/prompts": "2.4.5",
"@types/react": "18.2.0",
"@types/react-dom": "18.2.0",
"@typescript-eslint/eslint-plugin": "5.57.1",
Expand Down
13 changes: 5 additions & 8 deletions src/analytics/patch/usePatchAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
PatchQueryVariables,
TaskSortCategory,
} from "gql/generated/types";
import { GET_PATCH } from "gql/queries";
import { PATCH } from "gql/queries";

type Action =
| { name: "Filter Tasks"; filterBy: string }
Expand Down Expand Up @@ -49,13 +49,10 @@ type Action =
| { name: "Open Schedule Tasks Modal" };

export const usePatchAnalytics = (id: string) => {
const { data: eventData } = useQuery<PatchQuery, PatchQueryVariables>(
GET_PATCH,
{
variables: { id },
fetchPolicy: "cache-first",
}
);
const { data: eventData } = useQuery<PatchQuery, PatchQueryVariables>(PATCH, {
variables: { id },
fetchPolicy: "cache-first",
});
const { status } = eventData?.patch || {};

return useAnalyticsRoot<Action>("Patch", {
Expand Down
6 changes: 3 additions & 3 deletions src/analytics/task/useAnnotationAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
AnnotationEventDataQuery,
AnnotationEventDataQueryVariables,
} from "gql/generated/types";
import { GET_ANNOTATION_EVENT_DATA, GET_BUILD_BARON } from "gql/queries";
import { ANNOTATION_EVENT_DATA, BUILD_BARON } from "gql/queries";
import { RequiredQueryParams } from "types/task";
import { queryString } from "utils";

Expand Down Expand Up @@ -36,13 +36,13 @@ export const useAnnotationAnalytics = () => {
const { data: eventData } = useQuery<
AnnotationEventDataQuery,
AnnotationEventDataQueryVariables
>(GET_ANNOTATION_EVENT_DATA, {
>(ANNOTATION_EVENT_DATA, {
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
});

const { data: bbData } = useQuery<BuildBaronQuery, BuildBaronQueryVariables>(
GET_BUILD_BARON,
BUILD_BARON,
{
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
Expand Down
13 changes: 5 additions & 8 deletions src/analytics/task/useTaskAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TaskSortCategory,
TestSortCategory,
} from "gql/generated/types";
import { GET_TASK } from "gql/queries";
import { TASK } from "gql/queries";
import { CommitType } from "pages/task/actionButtons/previousCommits/types";
import { RequiredQueryParams, LogTypes } from "types/task";
import { queryString } from "utils";
Expand Down Expand Up @@ -71,13 +71,10 @@ export const useTaskAnalytics = () => {

const parsed = parseQueryString(location.search);
const execution = Number(parsed[RequiredQueryParams.Execution]);
const { data: eventData } = useQuery<TaskQuery, TaskQueryVariables>(
GET_TASK,
{
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
}
);
const { data: eventData } = useQuery<TaskQuery, TaskQueryVariables>(TASK, {
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
});

const {
failedTestCount,
Expand Down
Loading

0 comments on commit 9ab1c42

Please sign in to comment.