From b415c15c1daa564248ba04e894f52541b8e8de10 Mon Sep 17 00:00:00 2001 From: strzinek Date: Thu, 12 May 2022 22:16:39 +0200 Subject: [PATCH] support infra container; new tests --- src/Containers.jsx | 3 --- src/PodCreateModal.jsx | 20 +++++++++++++++++--- test/check-application | 31 +++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/Containers.jsx b/src/Containers.jsx index 4b90a5d72..e0730b148 100644 --- a/src/Containers.jsx +++ b/src/Containers.jsx @@ -497,9 +497,6 @@ class Containers extends React.Component { ); } - // Remove infra containers - filtered = filtered.filter(id => !this.props.containers[id].IsInfra); - filtered.sort((a, b) => { // Show unhealthy containers first if (this.props.containersDetails[a] && this.props.containersDetails[b]) { diff --git a/src/PodCreateModal.jsx b/src/PodCreateModal.jsx index 7e066310c..d406d74aa 100644 --- a/src/PodCreateModal.jsx +++ b/src/PodCreateModal.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { - Button, + Button, Checkbox, Form, FormGroup, Modal, Radio, TextInput, } from '@patternfly/react-core'; @@ -20,6 +20,7 @@ const systemOwner = "system"; export const PodCreateModal = ({ props, user, close }) => { const [podName, setPodName] = useState(dockerNames.getRandomName()); const [nameError, setNameError] = useState(null); + const [infra, setInfra] = useState(true); const [publish, setPublish] = useState([]); const [volumes, setVolumes] = useState([]); const [owner, setOwner] = useState(props.systemServiceAvailable ? systemOwner : user); @@ -32,6 +33,9 @@ export const PodCreateModal = ({ props, user, close }) => { if (podName) createConfig.name = podName; + if (!infra) + createConfig.no_infra = true; + if (publish.length > 0) createConfig.portmappings = publish .filter(port => port.containerPort) @@ -78,7 +82,9 @@ export const PodCreateModal = ({ props, user, close }) => { const onValueChanged = (key, value) => { if (key === "podName") { setPodName(value); - if (/^[a-zA-Z0-9][a-zA-Z0-9_\\.-]*$/.test(value)) { + if (value === "") { + setNameError(_("Pod name is required.")); + } else if (/^[a-zA-Z0-9][a-zA-Z0-9_\\.-]*$/.test(value)) { setNameError(null); } else { setNameError(_("Invalid characters. Name can only contain letters, numbers, and certain punctuation (_ . -).")); @@ -104,13 +110,21 @@ export const PodCreateModal = ({ props, user, close }) => { label={_("System")} id="create-pod-dialog-owner-system" isChecked={owner === systemOwner} + isDisabled={!props.systemServiceAvailable} onChange={() => setOwner(systemOwner)} /> setOwner(user)} /> + + setInfra(value)} /> + { onEscapePress={() => close() } title={_("Create pod")} footer={<> - {dialogError && } } > + {dialogError && } {defaultBody} ); diff --git a/test/check-application b/test/check-application index 02a5af707..164e93d0d 100755 --- a/test/check-application +++ b/test/check-application @@ -1375,6 +1375,37 @@ class TestApplication(testlib.MachineCase): b.click('.pf-c-modal-box__footer #create-image-create-run-btn') b.wait(lambda: self.getContainerAttr(container_name, "State", sel) in 'Running') + def performContainersKebabAction(self, cmd): + b = self.browser + b.click("#container-over-actions-dropdown") + b.click(f"#containers-containers .pf-c-card__header .pf-c-card__actions .pf-c-toolbar .pf-c-dropdown__menu li:contains({cmd})") + + def testCreatePodSystem(self): + self._testCreatePod(True) + + def testCreatePodUser(self): + self._testCreatePod(False) + + def _testCreatePod(self, auth): + b = self.browser + pod_name = "pod-create" + + self.login(auth) + + self.performContainersKebabAction("Create pod") + + b.wait_visible('#create-pod-dialog-name') + + b.set_input_text("#create-pod-dialog-name", pod_name) + + # Uncheck infra checkbox - tests are running offline and default infra image may not be available + b.set_checked("#create-pod-dialog-infra", False) + + b.click('#create-pod-create-btn') + b.wait_not_present("#create-pod-dialog-name") + + self.waitPodRow(pod_name, False) + @testlib.nondestructive def testRunImageSystem(self): self._testRunImage(True)