Skip to content

Commit

Permalink
Implement an ability to debug devworkspace startup (eclipse-che#369)
Browse files Browse the repository at this point in the history
* feat: implement an ability to debug devworkspace startup

Signed-off-by: Oleksii Orel <[email protected]>

* test: add workspace-indicator tests

Signed-off-by: Oleksii Orel <[email protected]>

* test: add DevWorkspaceClient debug mode tests
  • Loading branch information
olexii4 authored Oct 1, 2021
1 parent d3b478b commit 187048f
Show file tree
Hide file tree
Showing 17 changed files with 644 additions and 98 deletions.
3 changes: 1 addition & 2 deletions packages/common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"sourceMap": true
"rootDir": "src"
},
"include": [
"src",
Expand Down
3 changes: 1 addition & 2 deletions packages/dashboard-backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"@eclipse-che/common": ["../common/src"]
},
"outDir": "lib",
"rootDir": "src",
"sourceMap": true
"rootDir": "src"
},
"exclude": [
"node_modules",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import React from 'react';
import renderer, { ReactTestRendererJSON } from 'react-test-renderer';
import WorkspaceIndicator from '..';
import { WorkspaceStatus } from '../../../../services/helpers/types';
import { DevWorkspaceStatus, WorkspaceStatus } from '../../../../services/helpers/types';

jest.mock('react-tooltip', () => {
return function DummyTooltip(): React.ReactElement {
Expand All @@ -22,45 +22,58 @@ jest.mock('react-tooltip', () => {
});

describe('Workspace indicator component', () => {

it('should render STOPPED status correctly', () => {
const status = WorkspaceStatus.STOPPED;

const component = (<WorkspaceIndicator status={status} />);

expect(getComponentSnapshot(component)).toMatchSnapshot();
it('should render default status correctly', () => {
const element = (<WorkspaceIndicator status={'undefined'} />);
expect(renderer.create(element).toJSON()).toMatchSnapshot();
});

it('should render STARTING status correctly', () => {
const status = WorkspaceStatus.STARTING;

const component = (<WorkspaceIndicator status={status} />);

expect(getComponentSnapshot(component)).toMatchSnapshot();
describe('Che Workspaces', () => {
it('should render STOPPED status correctly', () => {
const element = (<WorkspaceIndicator status={WorkspaceStatus.STOPPED} />);
expect(getComponentSnapshot(element)).toMatchSnapshot();
});

it('should render STARTING status correctly', () => {
const element = (<WorkspaceIndicator status={WorkspaceStatus.STARTING} />);
expect(getComponentSnapshot(element)).toMatchSnapshot();
});

it('should render RUNNING status correctly', () => {
const element = (<WorkspaceIndicator status={WorkspaceStatus.RUNNING} />);
expect(getComponentSnapshot(element)).toMatchSnapshot();
});

it('should render ERROR status correctly', () => {
const element = (<WorkspaceIndicator status={WorkspaceStatus.ERROR} />);
expect(getComponentSnapshot(element)).toMatchSnapshot();
});

it('should render STOPPING status correctly', () => {
const element = (<WorkspaceIndicator status={WorkspaceStatus.STOPPING} />);
expect(getComponentSnapshot(element)).toMatchSnapshot();
});
});

it('should render RUNNING status correctly', () => {
const status = WorkspaceStatus.RUNNING;

const component = (<WorkspaceIndicator status={status} />);

expect(getComponentSnapshot(component)).toMatchSnapshot();
});

it('should render ERROR status correctly', () => {
const status = WorkspaceStatus.ERROR;

const component = (<WorkspaceIndicator status={status} />);

expect(getComponentSnapshot(component)).toMatchSnapshot();
});

it('should render STOPPING status correctly', () => {
const status = WorkspaceStatus.STOPPING;

const component = (<WorkspaceIndicator status={status} />);

expect(getComponentSnapshot(component)).toMatchSnapshot();
describe('DevWorkspaces', () => {
it('should render STOPPED status correctly', () => {
const element = (<WorkspaceIndicator status={DevWorkspaceStatus.STOPPED} />);
expect(getComponentSnapshot(element)).toMatchSnapshot();
});

it('should render RUNNING status correctly', () => {
const element = (<WorkspaceIndicator status={DevWorkspaceStatus.RUNNING} />);
expect(getComponentSnapshot(element)).toMatchSnapshot();
});

it('should render FAILED status correctly', () => {
const element = (<WorkspaceIndicator status={DevWorkspaceStatus.FAILED} />);
expect(getComponentSnapshot(element)).toMatchSnapshot();
});

it('should render FAILING status correctly', () => {
const element = (<WorkspaceIndicator status={DevWorkspaceStatus.FAILING} />);
expect(getComponentSnapshot(element)).toMatchSnapshot();
});
});

});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Workspace indicator component should render ERROR status correctly 1`] = `
exports[`Workspace indicator component Che Workspaces should render ERROR status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
Expand Down Expand Up @@ -31,7 +31,7 @@ Array [
]
`;

exports[`Workspace indicator component should render RUNNING status correctly 1`] = `
exports[`Workspace indicator component Che Workspaces should render RUNNING status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
Expand Down Expand Up @@ -62,7 +62,7 @@ Array [
]
`;

exports[`Workspace indicator component should render STARTING status correctly 1`] = `
exports[`Workspace indicator component Che Workspaces should render STARTING status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
Expand Down Expand Up @@ -93,7 +93,7 @@ Array [
]
`;

exports[`Workspace indicator component should render STOPPED status correctly 1`] = `
exports[`Workspace indicator component Che Workspaces should render STOPPED status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
Expand Down Expand Up @@ -130,7 +130,7 @@ Array [
]
`;

exports[`Workspace indicator component should render STOPPING status correctly 1`] = `
exports[`Workspace indicator component Che Workspaces should render STOPPING status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
Expand Down Expand Up @@ -160,3 +160,164 @@ Array [
</div>,
]
`;

exports[`Workspace indicator component DevWorkspaces should render FAILED status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
data-tip="FAILED"
>
<svg
aria-hidden={true}
aria-labelledby={null}
fill="red"
height="1em"
role="img"
style={
Object {
"verticalAlign": "-0.125em",
}
}
viewBox="0 0 512 512"
width="1em"
>
<path
d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"
/>
</svg>
</span>,
<div>
Dummy Tooltip
</div>,
]
`;

exports[`Workspace indicator component DevWorkspaces should render FAILING status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
data-tip="FAILING"
>
<svg
aria-hidden={true}
aria-labelledby={null}
fill="red"
height="1em"
role="img"
style={
Object {
"verticalAlign": "-0.125em",
}
}
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M513.417211,16.013668 L513.417211,112.013668 C513.406007,120.539653 520.082422,127.576718 528.597211,128.013668 C732.697211,136.513668 896.147211,305.013668 896.147211,511.343668 C896.147211,723.013668 724.007211,895.163668 512.417211,895.163668 C437.186239,895.277345 363.602574,873.135095 300.927211,831.523668 C294.58293,827.2982 286.138663,828.135095 280.747211,833.523668 L211.807211,902.353668 C208.502935,905.676185 206.82123,910.280199 207.20607,914.950237 C207.590911,919.620275 210.00361,923.886884 213.807211,926.623668 C300.709573,989.398037 405.213535,1023.13146 512.417211,1023.01398 C794.537211,1023.01398 1023.91724,793.433668 1023.91724,511.413668 C1024.00721,235.103668 804.007211,9.22366802 529.897211,0.00645736761 C525.571205,-0.116171039 521.377128,1.51204372 518.271915,4.52681369 C515.166702,7.54158367 513.415263,11.6857144 513.417211,16.013668 M97.1272107,212.923668 C64.2190689,258.479443 39.0698895,309.162997 22.6972107,362.923668 C21.2705092,367.756559 22.2039184,372.979173 25.2163356,377.018685 C28.2287528,381.058197 32.9681443,383.442545 38.0072107,383.453683 L139.407211,383.453683 C145.970195,383.46249 151.873012,379.462528 154.297211,373.363668 C164.307669,347.593304 177.068112,322.977652 192.357211,299.943668 C196.579666,293.633658 195.741339,285.216847 190.357211,279.863668 L121.497211,211.013668 C118.186635,207.662531 113.567544,205.940538 108.871166,206.30669 C104.174788,206.672841 99.8783994,209.089927 97.1272107,212.913668 M112.907211,511.433663 L17.0072107,511.433663 C12.679257,511.433663 8.5351263,513.183159 5.52035633,516.288373 C2.50558635,519.393586 0.877371594,523.587662 1.00721065,527.913668 C4.13104542,629.408217 37.6085847,727.635936 97.1172107,809.913668 C99.8539943,813.717268 104.120603,816.129968 108.790642,816.514809 C113.46068,816.899649 118.064693,815.217944 121.387211,811.913668 L190.217211,743.073668 C195.605784,737.682216 196.442679,729.237949 192.217211,722.893668 C153.520825,664.580171 131.611534,596.745437 128.887211,526.813668 C128.553964,518.220138 121.487197,511.427209 112.887211,511.433663"
/>
</svg>
</span>,
<div>
Dummy Tooltip
</div>,
]
`;

exports[`Workspace indicator component DevWorkspaces should render RUNNING status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
data-tip="RUNNING"
>
<svg
aria-hidden={true}
aria-labelledby={null}
fill="green"
height="1em"
role="img"
style={
Object {
"verticalAlign": "-0.125em",
}
}
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M512.1,0 C229.7,0 0,229.8 0,512 C0,794.3 229.8,1024 512.1,1024 C794.4,1024 1024,794.3 1024,512 C1024,229.7 794.4,0 512.1,0 Z M512,896 C300.2,896 128,723.9 128,512 C128,300.3 300.2,128 512,128 C723.7,128 896,300.2 896,512 C896,723.8 723.7,896 512,896 Z M512,224 C671.1,224 800,352.9 800,512 C800,671.1 671.1,800 512,800 C352.9,800 224,671.1 224,512 C224,352.9 352.9,224 512,224"
/>
</svg>
</span>,
<div>
Dummy Tooltip
</div>,
]
`;

exports[`Workspace indicator component DevWorkspaces should render STOPPED status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
data-tip="STOPPED"
>
<svg
aria-hidden="true"
fill="grey"
height="1em"
role="img"
style={
Object {
"verticalAlign": "-0.125em",
}
}
viewBox="0 0 16 16"
width="1em"
>
<path
d="M8.001,0 C3.589,0 0,3.590 0,8 C0,12.410 3.590,16 8.001,16 C12.412,16 16,12.410
16,8 C16,3.589 12.4125,0 8.001,0 Z M8,14 C4.690,14 2,11.310 2,8 C2,4.692 4.690,2
8,2 C11.307,2 14,4.690 14,8 C14,11.309 11.307,14 8,14 Z"
/>
<path
d="M8.001,3.5 C5.519,3.5 3.5,5.520 3.5,8 C3.5,10.481 5.520,12.5 8.000,12.5 C10.482,12.5 12.5,10.481
12.5,8 C12.5,5.519 10.482,3.5 8.000,3.5 Z M8,10.75 C6.483,10.75 5.25,9.517 5.25,8 C5.25,6.484
6.483,5.25 8,5.25 C9.516,5.25 10.75,6.483 10.75,8 C10.75,9.516 9.516,10.75 8,10.75 Z"
/>
</svg>
</span>,
<div>
Dummy Tooltip
</div>,
]
`;

exports[`Workspace indicator component should render default status correctly 1`] = `
Array [
<span
data-testid="workspace-status-indicator"
data-tip="UNDEFINED"
>
<svg
aria-hidden={true}
aria-labelledby={null}
fill="grey"
height="1em"
role="img"
style={
Object {
"verticalAlign": "-0.125em",
}
}
viewBox="0 0 1024 1024"
width="1em"
>
<path
d="M513.417211,16.013668 L513.417211,112.013668 C513.406007,120.539653 520.082422,127.576718 528.597211,128.013668 C732.697211,136.513668 896.147211,305.013668 896.147211,511.343668 C896.147211,723.013668 724.007211,895.163668 512.417211,895.163668 C437.186239,895.277345 363.602574,873.135095 300.927211,831.523668 C294.58293,827.2982 286.138663,828.135095 280.747211,833.523668 L211.807211,902.353668 C208.502935,905.676185 206.82123,910.280199 207.20607,914.950237 C207.590911,919.620275 210.00361,923.886884 213.807211,926.623668 C300.709573,989.398037 405.213535,1023.13146 512.417211,1023.01398 C794.537211,1023.01398 1023.91724,793.433668 1023.91724,511.413668 C1024.00721,235.103668 804.007211,9.22366802 529.897211,0.00645736761 C525.571205,-0.116171039 521.377128,1.51204372 518.271915,4.52681369 C515.166702,7.54158367 513.415263,11.6857144 513.417211,16.013668 M97.1272107,212.923668 C64.2190689,258.479443 39.0698895,309.162997 22.6972107,362.923668 C21.2705092,367.756559 22.2039184,372.979173 25.2163356,377.018685 C28.2287528,381.058197 32.9681443,383.442545 38.0072107,383.453683 L139.407211,383.453683 C145.970195,383.46249 151.873012,379.462528 154.297211,373.363668 C164.307669,347.593304 177.068112,322.977652 192.357211,299.943668 C196.579666,293.633658 195.741339,285.216847 190.357211,279.863668 L121.497211,211.013668 C118.186635,207.662531 113.567544,205.940538 108.871166,206.30669 C104.174788,206.672841 99.8783994,209.089927 97.1272107,212.913668 M112.907211,511.433663 L17.0072107,511.433663 C12.679257,511.433663 8.5351263,513.183159 5.52035633,516.288373 C2.50558635,519.393586 0.877371594,523.587662 1.00721065,527.913668 C4.13104542,629.408217 37.6085847,727.635936 97.1172107,809.913668 C99.8539943,813.717268 104.120603,816.129968 108.790642,816.514809 C113.46068,816.899649 118.064693,815.217944 121.387211,811.913668 L190.217211,743.073668 C195.605784,737.682216 196.442679,729.237949 192.217211,722.893668 C153.520825,664.580171 131.611534,596.745437 128.887211,526.813668 C128.553964,518.220138 121.487197,511.427209 112.887211,511.433663"
/>
</svg>
</span>,
<div>
Dummy Tooltip
</div>,
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class WorkspaceIndicator extends React.PureComponent<Props> {
color = 'green';
icon = <ResourcesFullIcon color={color} />;
break;
case DevWorkspaceStatus.FAILING:
color = 'red';
icon = <InProgressIcon className={styles.rotate} color={color} />;
break;
case DevWorkspaceStatus.FAILED:
case WorkspaceStatus.ERROR:
color = 'red';
Expand Down
Loading

0 comments on commit 187048f

Please sign in to comment.