Skip to content

Commit

Permalink
Add tests for Describe tab content in PVC and Pods (#1596)
Browse files Browse the repository at this point in the history
  • Loading branch information
cesnietor committed May 4, 2023
1 parent 29e7431 commit 27c254a
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 158 deletions.
242 changes: 128 additions & 114 deletions web-app/src/screens/Console/Tenants/TenantDetails/pods/PodDescribe.tsx
Expand Up @@ -181,16 +181,18 @@ const HeaderSection = ({ title }: { title: string }) => {
const PodDescribeSummary = ({ describeInfo }: IPodDescribeSummaryProps) => {
return (
<React.Fragment>
<HeaderSection title={"Summary"} />
<Box sx={{ ...twoColCssGridLayoutConfig }}>
<LabelValuePair label={"Name"} value={describeInfo.name} />
<LabelValuePair label={"Namespace"} value={describeInfo.namespace} />
<LabelValuePair label={"Node"} value={describeInfo.nodeName} />
<LabelValuePair label={"Start time"} value={describeInfo.startTime} />
<LabelValuePair label={"Status"} value={describeInfo.phase} />
<LabelValuePair label={"QoS Class"} value={describeInfo.qosClass} />
<LabelValuePair label={"IP"} value={describeInfo.podIP} />
</Box>
<div id="pod-describe-summary-content">
<HeaderSection title={"Summary"} />
<Box sx={{ ...twoColCssGridLayoutConfig }}>
<LabelValuePair label={"Name"} value={describeInfo.name} />
<LabelValuePair label={"Namespace"} value={describeInfo.namespace} />
<LabelValuePair label={"Node"} value={describeInfo.nodeName} />
<LabelValuePair label={"Start time"} value={describeInfo.startTime} />
<LabelValuePair label={"Status"} value={describeInfo.phase} />
<LabelValuePair label={"QoS Class"} value={describeInfo.qosClass} />
<LabelValuePair label={"IP"} value={describeInfo.podIP} />
</Box>
</div>
</React.Fragment>
);
};
Expand All @@ -200,87 +202,97 @@ const PodDescribeAnnotations = ({
}: IPodDescribeAnnotationsProps) => {
return (
<React.Fragment>
<HeaderSection title={"Annotations"} />
<Box>
{annotations.map((annotation, index) => (
<Chip
style={{ margin: "0.5%" }}
label={`${annotation.key}: ${annotation.value}`}
key={index}
/>
))}
</Box>
<div id="pod-describe-annotations-content">
<HeaderSection title={"Annotations"} />
<Box>
{annotations.map((annotation, index) => (
<Chip
style={{ margin: "0.5%" }}
label={`${annotation.key}: ${annotation.value}`}
key={index}
/>
))}
</Box>
</div>
</React.Fragment>
);
};

const PodDescribeLabels = ({ labels }: IPodDescribeLabelsProps) => {
return (
<React.Fragment>
<HeaderSection title={"Labels"} />
<Box>
{labels.map((label, index) => (
<Chip
style={{ margin: "0.5%" }}
label={`${label.key}: ${label.value}`}
key={index}
/>
))}
</Box>
<div id="pod-describe-labels-content">
<HeaderSection title={"Labels"} />
<Box>
{labels.map((label, index) => (
<Chip
style={{ margin: "0.5%" }}
label={`${label.key}: ${label.value}`}
key={index}
/>
))}
</Box>
</div>
</React.Fragment>
);
};

const PodDescribeConditions = ({ conditions }: IPodDescribeConditionsProps) => {
return (
<PodDescribeTable
title="Conditions"
columns={["type", "status"]}
columnsLabels={["Type", "Status"]}
items={conditions}
/>
<div id="pod-describe-conditions-content">
<PodDescribeTable
title="Conditions"
columns={["type", "status"]}
columnsLabels={["Type", "Status"]}
items={conditions}
/>
</div>
);
};

const PodDescribeTolerations = ({
tolerations,
}: IPodDescribeTolerationsProps) => {
return (
<PodDescribeTable
title="Tolerations"
columns={["effect", "key", "operator", "tolerationSeconds"]}
columnsLabels={["Effect", "Key", "Operator", "Seconds of toleration"]}
items={tolerations}
/>
<div id="pod-describe-tolerations-content">
<PodDescribeTable
title="Tolerations"
columns={["effect", "key", "operator", "tolerationSeconds"]}
columnsLabels={["Effect", "Key", "Operator", "Seconds of toleration"]}
items={tolerations}
/>
</div>
);
};

const PodDescribeVolumes = ({ volumes }: IPodDescribeVolumesProps) => {
return (
<React.Fragment>
{volumes.map((volume, index) => (
<React.Fragment key={index}>
<HeaderSection title={`Volume ${volume.name}`} />
<Box sx={{ ...twoColCssGridLayoutConfig }}>
{volume.pvc && (
<React.Fragment>
<LabelValuePair
label={"Type"}
value="Persistant Volume Claim"
/>
<LabelValuePair
label={"Claim Name"}
value={volume.pvc.claimName}
/>
</React.Fragment>
)}
{/* TODO Add component to display projected data (Maybe change API response) */}
{volume.projected && (
<LabelValuePair label={"Type"} value="Projected" />
)}
</Box>
</React.Fragment>
))}
<div id="pod-describe-volumes-content">
{volumes.map((volume, index) => (
<React.Fragment key={index}>
<HeaderSection title={`Volume ${volume.name}`} />
<Box sx={{ ...twoColCssGridLayoutConfig }}>
{volume.pvc && (
<React.Fragment>
<LabelValuePair
label={"Type"}
value="Persistant Volume Claim"
/>
<LabelValuePair
label={"Claim Name"}
value={volume.pvc.claimName}
/>
</React.Fragment>
)}
{/* TODO Add component to display projected data (Maybe change API response) */}
{volume.projected && (
<LabelValuePair label={"Type"} value="Projected" />
)}
</Box>
</React.Fragment>
))}
</div>
</React.Fragment>
);
};
Expand Down Expand Up @@ -325,57 +337,59 @@ const PodDescribeTable = ({
const PodDescribeContainers = ({ containers }: IPodDescribeContainersProps) => {
return (
<React.Fragment>
{containers.map((container, index) => (
<React.Fragment key={index}>
<HeaderSection title={`Container ${container.name}`} />
<Box
style={{ wordBreak: "break-all" }}
sx={{ ...twoColCssGridLayoutConfig }}
>
<LabelValuePair label={"Image"} value={container.image} />
<LabelValuePair label={"Ready"} value={`${container.ready}`} />
<LabelValuePair
label={"Ports"}
value={container.ports.join(", ")}
/>
<LabelValuePair
label={"Host Ports"}
value={container.hostPorts.join(", ")}
<div id="pod-describe-containers-content">
{containers.map((container, index) => (
<React.Fragment key={index}>
<HeaderSection title={`Container ${container.name}`} />
<Box
style={{ wordBreak: "break-all" }}
sx={{ ...twoColCssGridLayoutConfig }}
>
<LabelValuePair label={"Image"} value={container.image} />
<LabelValuePair label={"Ready"} value={`${container.ready}`} />
<LabelValuePair
label={"Ports"}
value={container.ports.join(", ")}
/>
<LabelValuePair
label={"Host Ports"}
value={container.hostPorts.join(", ")}
/>
<LabelValuePair
label={"Arguments"}
value={container.args.join(", ")}
/>
<LabelValuePair
label={"Started"}
value={container.state?.started}
/>
<LabelValuePair label={"State"} value={container.state?.state} />
</Box>
<Box
style={{ wordBreak: "break-all" }}
sx={{ ...twoColCssGridLayoutConfig }}
>
<LabelValuePair label={"Image ID"} value={container.imageID} />
<LabelValuePair
label={"Container ID"}
value={container.containerID}
/>
</Box>
<PodDescribeTable
title="Mounts"
columns={["name", "mountPath"]}
columnsLabels={["Name", "Mount Path"]}
items={container.mounts}
/>
<LabelValuePair
label={"Arguments"}
value={container.args.join(", ")}
<PodDescribeTable
title="Environment Variables"
columns={["key", "value"]}
columnsLabels={["Key", "Value"]}
items={container.environmentVariables}
/>
<LabelValuePair
label={"Started"}
value={container.state?.started}
/>
<LabelValuePair label={"State"} value={container.state?.state} />
</Box>
<Box
style={{ wordBreak: "break-all" }}
sx={{ ...twoColCssGridLayoutConfig }}
>
<LabelValuePair label={"Image ID"} value={container.imageID} />
<LabelValuePair
label={"Container ID"}
value={container.containerID}
/>
</Box>
<PodDescribeTable
title="Mounts"
columns={["name", "mountPath"]}
columnsLabels={["Name", "Mount Path"]}
items={container.mounts}
/>
<PodDescribeTable
title="Environment Variables"
columns={["key", "value"]}
columnsLabels={["Key", "Value"]}
items={container.environmentVariables}
/>
</React.Fragment>
))}
</React.Fragment>
))}
</div>
</React.Fragment>
);
};
Expand Down

0 comments on commit 27c254a

Please sign in to comment.