throw error on bad response from UpRock, fix empty view condition
This commit is contained in:
1 parent
064a9f6d36
commit
9cbee6d32b
3 files changed
+32
-11
No files matched your search
@@ -61,8 +61,11 @@ const DistributedUptimeDetails = () => {
|
|||||||
</GenericFallback>
|
</GenericFallback>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
if (typeof monitor === "undefined" || monitor.totalChecks === 0) {
|
typeof monitor === "undefined" ||
|
||||||
|
typeof monitor?.totalChecks === "undefined" ||
|
||||||
|
monitor?.totalChecks === 0
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
<Stack gap={theme.spacing(10)}>
|
<Stack gap={theme.spacing(10)}>
|
||||||
<Breadcrumbs list={BREADCRUMBS} />
|
<Breadcrumbs list={BREADCRUMBS} />
|
||||||
|
|||||||
+2
-1
@@ -3,4 +3,5 @@ node_modules
|
|||||||
*.log
|
*.log
|
||||||
*.sh
|
*.sh
|
||||||
.nyc_output
|
.nyc_output
|
||||||
coverage
|
coverage
|
||||||
|
.clinic
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import jmespath from 'jmespath';
|
import jmespath from "jmespath";
|
||||||
const SERVICE_NAME = "NetworkService";
|
const SERVICE_NAME = "NetworkService";
|
||||||
const UPROCK_ENDPOINT = "https://api.uprock.com/checkmate/push";
|
const UPROCK_ENDPOINT = "https://api.uprock.com/checkmate/push";
|
||||||
|
|
||||||
@@ -123,7 +123,17 @@ class NetworkService {
|
|||||||
*/
|
*/
|
||||||
async requestHttp(job) {
|
async requestHttp(job) {
|
||||||
try {
|
try {
|
||||||
const { url, secret, _id, name, teamId, type, jsonPath, matchMethod, expectedValue } = job.data;
|
const {
|
||||||
|
url,
|
||||||
|
secret,
|
||||||
|
_id,
|
||||||
|
name,
|
||||||
|
teamId,
|
||||||
|
type,
|
||||||
|
jsonPath,
|
||||||
|
matchMethod,
|
||||||
|
expectedValue,
|
||||||
|
} = job.data;
|
||||||
const config = {};
|
const config = {};
|
||||||
|
|
||||||
secret !== undefined && (config.headers = { Authorization: `Bearer ${secret}` });
|
secret !== undefined && (config.headers = { Authorization: `Bearer ${secret}` });
|
||||||
@@ -144,7 +154,8 @@ class NetworkService {
|
|||||||
const code = error.response?.status || this.NETWORK_ERROR;
|
const code = error.response?.status || this.NETWORK_ERROR;
|
||||||
httpResponse.code = code;
|
httpResponse.code = code;
|
||||||
httpResponse.status = false;
|
httpResponse.status = false;
|
||||||
httpResponse.message = this.http.STATUS_CODES[code] || this.stringService.httpNetworkError;
|
httpResponse.message =
|
||||||
|
this.http.STATUS_CODES[code] || this.stringService.httpNetworkError;
|
||||||
return httpResponse;
|
return httpResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,13 +175,13 @@ class NetworkService {
|
|||||||
service: this.SERVICE_NAME,
|
service: this.SERVICE_NAME,
|
||||||
method: "requestHttp",
|
method: "requestHttp",
|
||||||
message: `Job: [${name}](${_id}) match result with expected value`,
|
message: `Job: [${name}](${_id}) match result with expected value`,
|
||||||
details: { expectedValue, result, jsonPath, matchMethod }
|
details: { expectedValue, result, jsonPath, matchMethod },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (jsonPath) {
|
if (jsonPath) {
|
||||||
const contentType = response.headers['content-type'];
|
const contentType = response.headers["content-type"];
|
||||||
|
|
||||||
const isJson = contentType?.includes('application/json');
|
const isJson = contentType?.includes("application/json");
|
||||||
if (!isJson) {
|
if (!isJson) {
|
||||||
httpResponse.status = false;
|
httpResponse.status = false;
|
||||||
httpResponse.message = this.stringService.httpNotJson;
|
httpResponse.message = this.stringService.httpNotJson;
|
||||||
@@ -199,7 +210,9 @@ class NetworkService {
|
|||||||
else match = result === expectedValue;
|
else match = result === expectedValue;
|
||||||
|
|
||||||
httpResponse.status = match;
|
httpResponse.status = match;
|
||||||
httpResponse.message = match ? this.stringService.httpMatchSuccess : this.stringService.httpMatchFail;
|
httpResponse.message = match
|
||||||
|
? this.stringService.httpMatchSuccess
|
||||||
|
: this.stringService.httpMatchFail;
|
||||||
return httpResponse;
|
return httpResponse;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = this.SERVICE_NAME;
|
error.service = this.SERVICE_NAME;
|
||||||
@@ -308,7 +321,8 @@ class NetworkService {
|
|||||||
if (error) {
|
if (error) {
|
||||||
dockerResponse.status = false;
|
dockerResponse.status = false;
|
||||||
dockerResponse.code = error.statusCode || this.NETWORK_ERROR;
|
dockerResponse.code = error.statusCode || this.NETWORK_ERROR;
|
||||||
dockerResponse.message = error.reason || "Failed to fetch Docker container information";
|
dockerResponse.message =
|
||||||
|
error.reason || "Failed to fetch Docker container information";
|
||||||
return dockerResponse;
|
return dockerResponse;
|
||||||
}
|
}
|
||||||
dockerResponse.status = response?.State?.Status === "running" ? true : false;
|
dockerResponse.status = response?.State?.Status === "running" ? true : false;
|
||||||
@@ -397,6 +411,9 @@ class NetworkService {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
if (response.data.success === false) {
|
||||||
|
throw new Error(response.data.message);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error.message);
|
console.log(error.message);
|
||||||
error.service = this.SERVICE_NAME;
|
error.service = this.SERVICE_NAME;
|
||||||
|
|||||||
Reference in new issue
Block a user