Skip to content

Commit

Permalink
Feature: rendering server/agent errors for build and steps (#20)
Browse files Browse the repository at this point in the history
* improving build preview css classes

* added build error message on buildItem

* rendering step error

* implemented build error tests

* implemented step error log with tests

* implemented steps server error tests
  • Loading branch information
plyr4 authored Nov 14, 2019
1 parent a2be651 commit 444c111
Show file tree
Hide file tree
Showing 8 changed files with 326 additions and 37 deletions.
27 changes: 27 additions & 0 deletions cypress/fixtures/build_error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"id": 5,
"repo_id": 1,
"number": 5,
"parent": 1,
"event": "push",
"status": "error",
"error": "failure authenticating",
"enqueued": 1572980376,
"created": 1572980376,
"started": 1572980375,
"finished": 1572980375,
"deploy": "",
"clone": "https://github.com/go-vela/ui.git",
"source": "https://github.com/go-vela/ui/commit/9b1d8bded6e992ab660eaee527c5e3232d0a2441",
"title": "push received from https://github.com/go-vela/ui",
"message": "fixing docker params",
"commit": "9b1d8bded6e992ab660eaee527c5e3232d0a2441",
"sender": "DavidVader",
"author": "DavidVader",
"branch": "infra",
"ref": "refs/heads/infra",
"base_ref": "",
"host": "",
"runtime": "docker",
"distribution": "linux"
}
6 changes: 3 additions & 3 deletions cypress/fixtures/steps_5.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"number": 1,
"name": "clone",
"stage": "go",
"status": "failure",
"status": "success",
"error": "",
"exit_code": 1,
"created": 1572029883,
Expand All @@ -23,7 +23,7 @@
"number": 2,
"name": "build",
"stage": "go",
"status": "failure",
"status": "success",
"error": "",
"exit_code": 2,
"created": 1572029883,
Expand Down Expand Up @@ -57,7 +57,7 @@
"number": 4,
"name": "publish",
"stage": "go",
"status": "failure",
"status": "running",
"error": "",
"exit_code": 2,
"created": 1572029883,
Expand Down
87 changes: 87 additions & 0 deletions cypress/fixtures/steps_error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[
{
"id": 1,
"build_id": 1,
"repo_id": 1,
"number": 1,
"name": "clone",
"stage": "go",
"status": "error",
"error": "problem starting container",
"exit_code": 1,
"created": 1572029883,
"started": 1572029935,
"finished": 1572029937,
"host": "",
"runtime": "docker",
"distribution": "linux"
},
{
"id": 2,
"build_id": 1,
"repo_id": 1,
"number": 2,
"name": "build",
"stage": "go",
"status": "success",
"error": "",
"exit_code": 2,
"created": 1572029883,
"started": 1572029928,
"finished": 1572029935,
"host": "",
"runtime": "docker",
"distribution": "linux"
},
{
"id": 3,
"build_id": 1,
"repo_id": 1,
"number": 3,
"name": "test",
"stage": "go",
"status": "running",
"error": "",
"exit_code": 2,
"created": 1572029883,
"started": 1572029928,
"finished": 0,
"host": "",
"runtime": "docker",
"distribution": "linux"
},
{
"id": 4,
"build_id": 1,
"repo_id": 1,
"number": 4,
"name": "publish",
"stage": "go",
"status": "pending",
"error": "",
"exit_code": 2,
"created": 1572029883,
"started": 1572029928,
"finished": 0,
"host": "",
"runtime": "docker",
"distribution": "linux"
},
{
"id": 5,
"build_id": 1,
"repo_id": 1,
"number": 5,
"name": "echo",
"stage": "go",
"status": "success",
"error": "",
"exit_code": 2,
"created": 1572029883,
"started": 1572029928,
"finished": 0,
"host": "",
"runtime": "docker",
"distribution": "linux"
}
]
23 changes: 23 additions & 0 deletions cypress/integration/build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,28 @@ context("org/repo/build View Build Page", () => {
cy.get("@buildStatus").should("have.class", "-failure");
});
});

context("visit build with server error", () => {
beforeEach(() => {
cy.visit("/someorg/somerepo/5");
cy.get("[data-test=full-build]").as("build");
cy.get("@build")
.get("[data-test=build-status]")
.as("buildStatus");
});

it("build should have failure style", () => {
cy.get("@buildStatus").should("have.class", "-failure");
});

it("build error should show", () => {
cy.get("[data-test=build-error]").should("be.visible");
});

it("build error should contain error", () => {
cy.get("[data-test=build-error]").contains("error:");
cy.get("[data-test=build-error]").contains("failure authenticating");
});
});
});
});
53 changes: 53 additions & 0 deletions cypress/integration/steps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,57 @@ context("org/repo Builds Page", () => {
.should("be.not.visible");
});
});
context("visit build/steps with server error", () => {
beforeEach(() => {
cy.server();
cy.stubBuild();
cy.stubStepsWithErrorLogs();
cy.login("/someorg/somerepo/5");
cy.get("[data-test=steps]").as("steps");
cy.get("[data-test=step]").as("step");
cy.get("[data-test=logs]").as("logs");
cy.get("[data-test=step-header]")
.children()
.as("stepHeaders");
cy.get("[data-test=full-build]").as("build");
cy.get("@build")
.get("[data-test=build-status]")
.as("buildStatus");
});

it("build should have failure style", () => {
cy.get("@buildStatus").should("have.class", "-failure");
});

it("build error should show", () => {
cy.get("[data-test=build-error]").should("be.visible");
});

it("build error should contain error", () => {
cy.get("[data-test=build-error]").contains("error:");
cy.get("[data-test=build-error]").contains("failure authenticating");
});

it("first step should contain error", () => {
cy.get("[data-test=step]")
.first()
.as("cloneStep");
cy.get("@cloneStep")
.should("be.visible")
.click();
cy.get("@cloneStep").contains("error:");
cy.get("@cloneStep").contains("problem starting container");
});

it("last step should not contain error", () => {
cy.get("[data-test=step]")
.last()
.as("echoStep");
cy.get("@echoStep")
.should("be.visible")
.click({ force: true });
cy.get("@echoStep").should("not.contain", "error:");
cy.get("@echoStep").contains("$");
});
});
});
28 changes: 28 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Cypress.Commands.add("stubBuild", () => {
cy.fixture("build_pending.json").as("pendingBuild");
cy.fixture("build_success.json").as("successBuild");
cy.fixture("build_failure.json").as("failureBuild");
cy.fixture("build_error.json").as("errorBuild");
cy.route({
method: "GET",
url: "api/v1/repos/*/*/builds/1",
Expand All @@ -58,6 +59,12 @@ Cypress.Commands.add("stubBuild", () => {
status: 200,
response: "@failureBuild"
});
cy.route({
method: "GET",
url: "api/v1/repos/*/*/builds/5",
status: 200,
response: "@errorBuild"
});
});

Cypress.Commands.add("stubBuilds", () => {
Expand Down Expand Up @@ -103,6 +110,27 @@ Cypress.Commands.add("stubStepsWithLogs", () => {
});
});

Cypress.Commands.add("stubStepsWithErrorLogs", () => {
cy.server();
cy.fixture("steps_error.json").as("steps");
cy.route({
method: "GET",
url: "api/v1/repos/*/*/builds/*/steps",
status: 200,
response: "@steps"
});
cy.fixture("logs").then(logs => {
for (let i = 0; i < logs.length; i++) {
cy.route({
method: "GET",
url: "api/v1/repos/*/*/builds/*/steps/" + logs[i]["step_id"] + "/logs",
status: 200,
response: logs[i]
});
}
});
});

Cypress.Commands.add("stubBuildsErrors", () => {
cy.route({
method: "GET",
Expand Down
Loading

0 comments on commit 444c111

Please sign in to comment.