Monitoring and Audit Log config screen UI tests (#2179)

This commit is contained in:
jinapurapu
2022-07-19 17:10:21 -07:00
committed by GitHub
parent 8e857dc563
commit 1c58a543b6
6 changed files with 418 additions and 116 deletions

View File

@@ -347,7 +347,7 @@ const TenantMonitoring = ({ classes }: ITenantMonitoring) => {
<Fragment>
<Grid item xs={12} paddingBottom={2}>
<InputBoxWrapper
id={`image`}
id={`prometheus_image`}
label={"Image"}
placeholder={"quay.io/prometheus/prometheus:latest"}
name={`image`}

View File

@@ -86,7 +86,7 @@ const KeyPairEdit = ({
<Grid paddingBottom={1}>
<div className={classes.shortened}>
<InputBoxWrapper
id={`key-${index.toString()}`}
id={`key-${paramName.replace(/ /g, "")}-${index.toString()}`}
label={""}
placeholder={"Key"}
name={`key-${index.toString()}`}
@@ -102,7 +102,7 @@ const KeyPairEdit = ({
error={error[`key-${index.toString()}`] || ""}
/>
<InputBoxWrapper
id={`val-${index.toString()}`}
id={`val-${paramName.replace(/ /g, "")}-${index.toString()}`}
label={""}
placeholder={"Value"}
name={`val-${index.toString()}`}
@@ -119,6 +119,7 @@ const KeyPairEdit = ({
/>
<Tooltip title={`Add ${paramName}`} aria-label="addlabel">
<IconButton
id={`add-${paramName.replace(/ /g, "")}-${index.toString()}`}
size={"small"}
onClick={() => {
let tempLabels = [...newValues];
@@ -131,6 +132,7 @@ const KeyPairEdit = ({
</Tooltip>
<Tooltip title="Remove" aria-label="removeLabel">
<IconButton
id={`remove-${paramName.replace(/ /g, "")}-${index.toString()}`}
size={"small"}
style={{ marginLeft: 16 }}
onClick={() => {

View File

@@ -14,7 +14,6 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//import { ISecurityContext} from "../types";
import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";
@@ -341,6 +340,7 @@ const LoggingDBDetails = ({
<Grid item xs={12} textAlign={"right"}>
<Button
type="submit"
id={"submit_button"}
variant="contained"
color="primary"
disabled={!checkValid()}

View File

@@ -98,9 +98,9 @@ const SecurityContextSelector = ({
<Grid item xs={12}>
<div className={classes.multiContainer}>
<FormSwitchWrapper
value="prometheusSecurityContextRunAsNonRoot"
id="prometheus_securityContext_runAsNonRoot"
name="prometheus_securityContext_runAsNonRoot"
value="SecurityContextRunAsNonRoot"
id="securityContext_runAsNonRoot"
name="securityContext_runAsNonRoot"
checked={runAsNonRoot}
onChange={() => {
dispatch(setRunAsNonRoot(!runAsNonRoot));

View File

@@ -25,8 +25,9 @@ import {
goToPodSection,
goToPvcInTenant,
goToPvcSection,
checkMonitoringFieldsAcceptValues,
checkLoggingFieldsAcceptValues,
goToMonitoringSection,
goToLoggingSection,
goToLoggingDBSection,
} from "./utils";
fixture("For user with default permissions").page("http://localhost:9090");
@@ -97,14 +98,415 @@ const checkPvcDescribeHasSections = async () => {
.ok();
};
export const checkMonitoringToggle = async (tenantName: string) => {
await goToMonitoringSection(tenantName);
await t
.click("#tenant-monitoring")
.click("#confirm-ok")
.wait(1000)
.expect(Selector("#image").exists)
.notOk()
.click("#yaml_button")
.expect(Selector("#code_wrapper").exists)
.ok();
await t
.expect(
(await Selector("#code_wrapper").textContent).includes("prometheus:")
)
.notOk();
await t
.click(Selector(`a[href$="/monitoring"]`))
.click("#tenant-monitoring")
.click("#confirm-ok")
.wait(1000)
.expect(Selector("#prometheus_image").exists)
.ok()
.click("#yaml_button")
.expect(Selector("#code_wrapper").exists)
.ok();
await t
.expect(
(await Selector("#code_wrapper").textContent).includes("prometheus:")
)
.ok();
};
export const checkMonitoringFieldsAcceptValues = async (tenantName: string) => {
await goToMonitoringSection(tenantName);
await t
.typeText("#prometheus_image", "quay.io/prometheus/prometheus:latest", {
replace: true,
})
.typeText("#sidecarImage", "library/alpine:latest", { replace: true })
.typeText("#initImage", "library/busybox:1.33.1", { replace: true })
.typeText("#diskCapacityGB", "1", { replace: true })
.typeText("#cpuRequest", "1", { replace: true })
.typeText("#memRequest", "1", { replace: true })
.typeText("#serviceAccountName", "monitoringTestServiceAccountName", {
replace: true,
})
.typeText("#storageClassName", "monitoringTestStorageClassName", {
replace: true,
})
.typeText("#securityContext_runAsUser", "1212", { replace: true })
.typeText("#securityContext_runAsGroup", "3434", { replace: true })
.typeText("#securityContext_fsGroup", "5656", { replace: true })
.expect(Selector("#securityContext_runAsNonRoot").checked)
.ok()
.click("#securityContext_runAsNonRoot")
.expect(Selector("#securityContext_runAsNonRoot").checked)
.notOk()
.typeText("#key-Labels-0", "monitoringLabelKey0Test", { replace: true })
.typeText("#val-Labels-0", "monitoringLabelVal0Test", { replace: true })
.click("#add-Labels-0")
.typeText("#key-Annotations-0", "monitoringAnnotationsKey0Test", {
replace: true,
})
.typeText("#val-Annotations-0", "monitoringAnnotationsVal0Test", {
replace: true,
})
.click("#add-Annotations-0")
.typeText("#key-NodeSelector-0", "monitoringNodeSelectorKey0Test", {
replace: true,
})
.typeText("#val-NodeSelector-0", "monitoringNodeSelectorVal0Test", {
replace: true,
})
.click("#add-NodeSelector-0")
.expect(Selector("#key-Labels-1").exists)
.ok()
.expect(Selector("#key-Annotations-1").exists)
.ok()
.expect(Selector("#key-NodeSelector-1").exists)
.ok()
.click("#submit_button")
.click("#yaml_button")
.expect(Selector("#code_wrapper").exists)
.ok();
await t
.expect(
(
await Selector("#code_wrapper").textContent
).includes("image: quay.io/prometheus/prometheus:latest")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("initimage: library/busybox:1.33.1")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("diskCapacityGB: 1")
)
.ok()
.expect((await Selector("#code_wrapper").textContent).includes('cpu: "1"'))
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("memory: 1Gi")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("serviceAccountName: monitoringTestServiceAccountName")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("sidecarimage: library/alpine:latest")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("storageClassName: monitoringTestStorageClassName")
)
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("fsGroup: 5656")
)
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("runAsGroup: 3434")
)
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("runAsUser: 1212")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("monitoringAnnotationsKey0Test: monitoringAnnotationsVal0Test")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes(
"monitoringNodeSelectorKey0Test: monitoringNodeSelectorVal0Test"
)
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("monitoringLabelKey0Test: monitoringLabelVal0Test")
)
.ok();
};
const checkLoggingToggle = async (tenantName: string) => {
await goToLoggingSection(tenantName);
await t
.click("#tenant_logging")
.click("#confirm-ok")
.wait(1000)
.expect(Selector("#image").exists)
.notOk()
.click("#yaml_button")
.expect(Selector("#code_wrapper").exists)
.ok();
await t
.expect((await Selector("#code_wrapper").textContent).includes("log:"))
.notOk();
await t
.click(Selector(`a[href$="/logging"]`))
.click("#tenant_logging")
.click("#confirm-ok")
.wait(1000)
.expect(Selector("#image").exists)
.ok()
.click("#yaml_button")
.expect(Selector("#code_wrapper").exists)
.ok();
await t
.expect((await Selector("#code_wrapper").textContent).includes("log:"))
.ok();
};
const checkLoggingFieldsAcceptValues = async (tenantName: string) => {
await goToLoggingSection(tenantName);
await t
.typeText("#image", "minio/operator:v4.4.22", { replace: true })
.typeText("#diskCapacityGB", "3", { replace: true })
.typeText("#cpuRequest", "3", { replace: true })
.typeText("#memRequest", "3", { replace: true })
.typeText("#serviceAccountName", "loggingTestServiceAccountName", {
replace: true,
})
.typeText("#securityContext_runAsUser", "1111", { replace: true })
.typeText("#securityContext_runAsGroup", "2222", { replace: true })
.typeText("#securityContext_fsGroup", "3333", { replace: true })
.expect(Selector("#securityContext_runAsNonRoot").checked)
.notOk()
.click("#securityContext_runAsNonRoot")
.expect(Selector("#securityContext_runAsNonRoot").checked)
.ok()
.typeText("#key-Labels-0", "loggingLabelKey0Test", { replace: true })
.typeText("#val-Labels-0", "loggingLabelVal0Test", { replace: true })
.click("#add-Labels-0")
.typeText("#key-Annotations-0", "loggingAnnotationsKey0Test", {
replace: true,
})
.typeText("#val-Annotations-0", "loggingAnnotationsVal0Test", {
replace: true,
})
.click("#add-Annotations-0")
.typeText("#key-NodeSelector-0", "loggingNodeSelectorKey0Test", {
replace: true,
})
.typeText("#val-NodeSelector-0", "loggingNodeSelectorVal0Test", {
replace: true,
})
.click("#add-NodeSelector-0")
.expect(Selector("#key-Labels-1").exists)
.ok()
.expect(Selector("#key-Annotations-1").exists)
.ok()
.expect(Selector("#key-NodeSelector-1").exists)
.ok()
.click("#submit_button")
.click("#yaml_button")
.expect(Selector("#code_wrapper").exists)
.ok();
await t
.expect(
(
await Selector("#code_wrapper").textContent
).includes("image: minio/operator:v4.4.22")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("diskCapacityGB: 3")
)
.ok()
.expect((await Selector("#code_wrapper").textContent).includes('cpu: "3"'))
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes('memory: "3"')
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("serviceAccountName: loggingTestServiceAccountName")
)
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("fsGroup: 3333")
)
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("runAsGroup: 2222")
)
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("runAsUser: 1111")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("AnnotationsKey0Test: loggingAnnotationsVal0Test")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("NodeSelectorKey0Test: loggingNodeSelectorVal0Test")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("loggingLabelKey0Test: loggingLabelVal0Test")
)
.ok();
};
const checkLoggingDBFieldsAcceptValues = async (tenantName: string) => {
await goToLoggingDBSection(tenantName);
await t
.typeText("#dbImage", "library/postgres:13", { replace: true })
.typeText("#dbInitImage", "library/busybox:1.33.1", { replace: true })
.typeText("#dbCPURequest", "4", { replace: true })
.typeText("#dbMemRequest", "4", { replace: true })
.typeText("#securityContext_runAsUser", "4444", { replace: true })
.typeText("#securityContext_runAsGroup", "5555", { replace: true })
.typeText("#securityContext_fsGroup", "6666", { replace: true })
.expect(Selector("#securityContext_runAsNonRoot").checked)
.notOk()
.click("#securityContext_runAsNonRoot")
.expect(Selector("#securityContext_runAsNonRoot").checked)
.ok()
.typeText("#key-dbLabels-0", "loggingdbLabelKey0Test", { replace: true })
.typeText("#val-dbLabels-0", "loggingdbLabelVal0Test", { replace: true })
.click("#add-dbLabels-0")
.typeText("#key-dbAnnotations-0", "loggingdbAnnotationsKey0Test", {
replace: true,
})
.typeText("#val-dbAnnotations-0", "loggingdbAnnotationsVal0Test", {
replace: true,
})
.click("#add-dbAnnotations-0")
.typeText("#key-DBNodeSelector-0", "loggingdbNodeSelectorKey0Test", {
replace: true,
})
.typeText("#val-DBNodeSelector-0", "loggingdbNodeSelectorVal0Test", {
replace: true,
})
.click("#add-DBNodeSelector-0")
.expect(Selector("#key-dbLabels-1").exists)
.ok()
.expect(Selector("#key-dbAnnotations-1").exists)
.ok()
.expect(Selector("#key-DBNodeSelector-1").exists)
.ok()
.click("#remove-dbLabels-1")
.click("#remove-dbAnnotations-1")
.click("#remove-DBNodeSelector-1")
.expect(Selector("#key-dbLabels-1").exists)
.notOk()
.expect(Selector("#key-dbAnnotations-1").exists)
.notOk()
.expect(Selector("#key-DBNodeSelector-1").exists)
.notOk()
.click("#submit_button")
.click("#yaml_button")
.expect(Selector("#code_wrapper").exists)
.ok();
await t
.expect(
(
await Selector("#code_wrapper").textContent
).includes("image: library/postgres:13")
)
.ok()
.expect((await Selector("#code_wrapper").textContent).includes('cpu: "4"'))
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes('memory: "4"')
)
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("fsGroup: 6666")
)
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("runAsGroup: 5555")
)
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("runAsUser: 4444")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("loggingdbAnnotationsKey0Test: loggingdbAnnotationsVal0Test")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("loggingdbNodeSelectorKey0Test: loggingdbNodeSelectorVal0Test")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("loggingdbLabelKey0Test: loggingdbLabelVal0Test")
)
.ok();
};
test("Test Prometheus monitoring can be disabled and enabled", async (t) => {
const tenantName = `storage-lite`;
await loginToOperator();
await checkMonitoringToggle(tenantName);
});
test("Test Prometheus config fields can be edited and submitted", async (t) => {
const tenantName = `storage-lite`;
await loginToOperator();
await checkMonitoringFieldsAcceptValues(tenantName);
});
test("Test Audit Logging can be disabled and enabled", async (t) => {
const tenantName = `storage-lite`;
await loginToOperator();
await checkLoggingToggle(tenantName);
});
test("Test Audit Log config fields can be edited and submitted", async (t) => {
const tenantName = `storage-lite`;
await loginToOperator();
await checkLoggingFieldsAcceptValues(tenantName);
await checkLoggingDBFieldsAcceptValues(tenantName);
});

View File

@@ -14,6 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { ok } from "assert";
import { Selector, t } from "testcafe";
const host: string = "http://localhost:9090";
@@ -119,6 +120,10 @@ export const goToLoggingSection = async (tenantName: string) => {
await t.click(`#list-tenant-${tenantName}`).wait(2000);
await t.click(Selector(`a[href$="/logging"]`));
};
export const goToLoggingDBSection = async (tenantName: string) => {
await t.click(Selector(`a[href$="/logging"]`));
await t.click(Selector("#simple-tab-1"));
};
export const redirectToTenantsList = async () => {
await redirectToPath(`${host}/tenants`);
@@ -127,110 +132,3 @@ export const redirectToTenantsList = async () => {
export const redirectToPath = async (path: string) => {
await t.navigateTo(path);
};
export const checkMonitoringFieldsAcceptValues = async (tenantName: string) => {
await goToMonitoringSection(tenantName);
await t
.typeText("#image", "quay.io/prometheus/prometheus:latest", {
replace: true,
})
.typeText("#sidecarImage", "library/alpine:latest", { replace: true })
.typeText("#initImage", "library/busybox:1.33.1", { replace: true })
.typeText("#diskCapacityGB", "1", { replace: true })
.typeText("#cpuRequest", "1", { replace: true })
.typeText("#memRequest", "1", { replace: true })
.typeText("#serviceAccountName", "monitoringTestServiceAccountName", {
replace: true,
})
.typeText("#storageClassName", "monitoringTestStorageClassName", {
replace: true,
})
.click("#submit_button")
.click("#yaml_button")
.expect(Selector("#code_wrapper").exists)
.ok();
await t
.expect(
(
await Selector("#code_wrapper").textContent
).includes("image: quay.io/prometheus/prometheus:latest")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("initimage: library/busybox:1.33.1")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("diskCapacityGB: 1")
)
.ok()
.expect((await Selector("#code_wrapper").textContent).includes('cpu: "1"'))
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes("memory: 1Gi")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("serviceAccountName: monitoringTestServiceAccountName")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("sidecarimage: library/alpine:latest")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("storageClassName: monitoringTestStorageClassName")
)
.ok();
};
export const checkLoggingFieldsAcceptValues = async (tenantName: string) => {
await goToLoggingSection(tenantName);
await t
.typeText("#image", "minio/operator:v4.4.22", { replace: true })
.typeText("#diskCapacityGB", "3", { replace: true })
.typeText("#cpuRequest", "3", { replace: true })
.typeText("#memRequest", "3", { replace: true })
.typeText("#serviceAccountName", "loggingTestServiceAccountName", {
replace: true,
})
.click("#submit_button")
.click("#yaml_button")
.expect(Selector("#code_wrapper").exists)
.ok();
await t
.expect(
(
await Selector("#code_wrapper").textContent
).includes("image: minio/operator:v4.4.22")
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("diskCapacityGB: 3")
)
.ok()
.expect((await Selector("#code_wrapper").textContent).includes('cpu: "3"'))
.ok()
.expect(
(await Selector("#code_wrapper").textContent).includes('memory: "3"')
)
.ok()
.expect(
(
await Selector("#code_wrapper").textContent
).includes("serviceAccountName: loggingTestServiceAccountName")
)
.ok();
};