Skip to content

Latest commit

 

History

History
690 lines (614 loc) · 35.9 KB

CATALOG.md

File metadata and controls

690 lines (614 loc) · 35.9 KB

test-network-function test case catalog

test-network-function contains a variety of Test Cases, as well as Test Case Building Blocks.

  • Test Cases: Traditional JUnit testcases, which are specified internally using Ginkgo.It. Test cases often utilize several Test Case Building Blocks.
  • Test Case Building Blocks: Self-contained building blocks, which perform a small task in the context of oc, ssh, shell, or some other Expecter.

Test Case Catalog

Test Cases are the specifications used to perform a meaningful test. Test cases may run once, or several times against several targets. CNF Certification includes a number of normative and informative tests to ensure CNFs follow best practices. Here is the list of available Test Cases:

Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/access-control/cluster-role-bindings tests that a Pod does not specify ClusterRoleBindings.
Result Type normative
Suggested Remediation In most cases, Pod's should not have ClusterRoleBindings. The suggested remediation is to remove the need for ClusterRoleBindings, if possible.
Best Practice Reference CNF Best Practice V1.2 Section 6.2.10 and 6.3.6
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/access-control/host-resource tests several aspects of CNF best practices, including: 1. The Pod does not have access to Host Node Networking. 2. The Pod does not have access to Host Node Ports. 3. The Pod cannot access Host Node IPC space. 4. The Pod cannot access Host Node PID space. 5. The Pod is not granted NET_ADMIN SCC. 6. The Pod is not granted SYS_ADMIN SCC. 7. The Pod does not run as root. 8. The Pod does not allow privileged escalation. 9. The Pod is not granted NET_RAW SCC. 10. The Pod is not granted IPC_LOCK SCC.
Result Type normative
Suggested Remediation Ensure that each Pod in the CNF abides by the suggested best practices listed in the test description. In some rare cases, not all best practices can be followed. For example, some CNFs may be required to run as root. Such exceptions should be handled on a case-by-case basis, and should provide a proper justification as to why the best practice(s) cannot be followed.
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/access-control/namespace tests that all CNF's resources (PUTs and CRs) belong to valid namespaces. A valid namespace meets the following conditions: (1) It was declared in the yaml config file under the targetNameSpaces tag. (2) It doesn't have any of the following prefixes: default, openshift-, istio- and aspenmesh-
Result Type normative
Suggested Remediation Ensure that your CNF utilizes namespaces declared in the yaml config file. Additionally, the namespaces should not start with "default, openshift-, istio- or aspenmesh-", except in rare cases.
Best Practice Reference CNF Best Practice V1.2 Section 6.2, 16.3.8 & 16.3.9
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/access-control/pod-automount-service-account-token check that all pods under test have automountServiceAccountToken set to false
Result Type normative
Suggested Remediation check that pod has automountServiceAccountToken set to false or pod is attached to service account which has automountServiceAccountToken set to false
Best Practice Reference
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/access-control/pod-role-bindings ensures that a CNF does not utilize RoleBinding(s) in a non-CNF Namespace.
Result Type normative
Suggested Remediation Ensure the CNF is not configured to use RoleBinding(s) in a non-CNF Namespace.
Best Practice Reference CNF Best Practice V1.2 Section 6.3.3 and 6.3.5
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/access-control/pod-service-account tests that each CNF Pod utilizes a valid Service Account.
Result Type normative
Suggested Remediation Ensure that the each CNF Pod is configured to use a valid Service Account
Best Practice Reference CNF Best Practice V1.2 Section 6.2.3 and 6.2.7
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/affiliated-certification/container-is-certified tests whether container images listed in the configuration file have passed the Red Hat Container Certification Program (CCP).
Result Type normative
Suggested Remediation Ensure that your container has passed the Red Hat Container Certification Program (CCP).
Best Practice Reference CNF Best Practice V1.2 Section 6.3.7
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/affiliated-certification/operator-is-certified tests whether CNF Operators listed in the configuration file have passed the Red Hat Operator Certification Program (OCP).
Result Type normative
Suggested Remediation Ensure that your Operator has passed Red Hat's Operator Certification Program (OCP).
Best Practice Reference CNF Best Practice V1.2 Section 6.2.12 and Section 6.3.3
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/diagnostic/clusterversion Extracts OCP versions from the cluster.
Result Type informative
Suggested Remediation
Best Practice Reference CNF Best Practice V1.2 Section 6.3.6
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/diagnostic/extract-node-information extracts informational information about the cluster.
Result Type informative
Suggested Remediation
Best Practice Reference CNF Best Practice V1.2 Section 6.3.6
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/diagnostic/list-cni-plugins lists CNI plugins
Result Type normative
Suggested Remediation
Best Practice Reference CNF Best Practice V1.2 Section 6.2.4 and 6.3.7
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/diagnostic/nodes-hw-info list nodes HW info
Result Type normative
Suggested Remediation
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/lifecycle/container-shutdown Ensure that the containers lifecycle pre-stop management feature is configured.
Result Type normative
Suggested Remediation It's considered best-practices to define prestop for proper management of container lifecycle. The prestop can be used to gracefully stop the container and clean resources (e.g., DB connection). The prestop can be configured using : 1) Exec : executes the supplied command inside the container 2) HTTP : executes HTTP request against the specified endpoint. When defined. K8s will handle shutdown of the container using the following: 1) K8s first execute the preStop hook inside the container. 2) K8s will wait for a grace period. 3) K8s will clean the remaining processes using KILL signal.
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/lifecycle/image-pull-policy Ensure that the containers under test are using IfNotPresent as Image Pull Policy..
Result Type normative
Suggested Remediation Ensure that the containers under test are using IfNotPresent as Image Pull Policy.
Best Practice Reference https://docs.google.com/document/d/1wRHMk1ZYUSVmgp_4kxvqjVOKwolsZ5hDXjr5MLy-wbg/edit# Section 15.6
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/lifecycle/pod-high-availability ensures that CNF Pods specify podAntiAffinity rules and replica value is set to more than 1.
Result Type informative
Suggested Remediation In high availability cases, Pod podAntiAffinity rule should be specified for pod scheduling and pod replica value is set to more than 1 .
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/lifecycle/pod-owner-type tests that CNF Pod(s) are deployed as part of a ReplicaSet(s)/StatefulSet(s).
Result Type normative
Suggested Remediation Deploy the CNF using ReplicaSet/StatefulSet.
Best Practice Reference CNF Best Practice V1.2 Section 6.3.3 and 6.3.8
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/lifecycle/pod-recreation tests that a CNF is configured to support High Availability. First, this test cordons and drains a Node that hosts the CNF Pod. Next, the test ensures that OpenShift can re-instantiate the Pod on another Node, and that the actual replica count matches the desired replica count.
Result Type normative
Suggested Remediation Ensure that CNF Pod(s) utilize a configuration that supports High Availability. Additionally, ensure that there are available Nodes in the OpenShift cluster that can be utilized in the event that a host Node fails.
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/lifecycle/pod-scheduling ensures that CNF Pods do not specify nodeSelector or nodeAffinity. In most cases, Pods should allow for instantiation on any underlying Node.
Result Type informative
Suggested Remediation In most cases, Pod's should not specify their host Nodes through nodeSelector or nodeAffinity. However, there are cases in which CNFs require specialized hardware specific to a particular class of Node. As such, this test is purely informative, and will not prevent a CNF from being certified. However, one should have an appropriate justification as to why nodeSelector and/or nodeAffinity is utilized by a CNF.
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/lifecycle/pod-termination-grace-period tests whether the terminationGracePeriod is CNF-specific, or if the default (30s) is utilized. This test is informative, and will not affect CNF Certification. In many cases, the default terminationGracePeriod is perfectly acceptable for a CNF.
Result Type informative
Suggested Remediation Choose a terminationGracePeriod that is appropriate for your given CNF. If the default (30s) is appropriate, then feel free to ignore this informative message. This test is meant to raise awareness around how Pods are terminated, and to suggest that a CNF is configured based on its requirements. In addition to a terminationGracePeriod, consider utilizing a termination hook in the case that your application requires special shutdown instructions.
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/lifecycle/scaling tests that CNF deployments support scale in/out operations. First, The test starts getting the current replicaCount (N) of the deployment/s with the Pod Under Test. Then, it executes the scale-in oc command for (N-1) replicas. Lastly, it executes the scale-out oc command, restoring the original replicaCount of the deployment/s.
Result Type normative
Suggested Remediation Make sure CNF deployments/replica sets can scale in/out successfully.
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/networking/icmpv4-connectivity checks that each CNF Container is able to communicate via ICMPv4 on the Default OpenShift network. This test case requires the Deployment of the debug daemonset.
Result Type normative
Suggested Remediation Ensure that the CNF is able to communicate via the Default OpenShift network. In some rare cases, CNFs may require routing table changes in order to communicate over the Default network. In other cases, if the Container base image does not provide the "ip" or "ping" binaries, this test may not be applicable. For instructions on how to exclude a particular container from ICMPv4 connectivity tests, consult: README.md.
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/networking/service-type tests that each CNF Service does not utilize NodePort(s).
Result Type normative
Suggested Remediation Ensure Services are not configured to use NodePort(s).
Best Practice Reference CNF Best Practice V1.2 Section 6.3.1
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/observability/container-logging check that all containers under test use standard input output and standard error when logging
Result Type informative
Suggested Remediation make sure containers are not redirecting stdout/stderr
Best Practice Reference CNF Best Practice V1.2 Section 11.1
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/observability/crd-status checks that all CRDs have a status subresource specification.
Result Type informative
Suggested Remediation make sure that all the CRDs have a meaningful status specification.
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/operator/install-source tests whether a CNF Operator is installed via OLM.
Result Type normative
Suggested Remediation Ensure that your Operator is installed via OLM.
Best Practice Reference CNF Best Practice V1.2 Section 6.2.12 and Section 6.3.3
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/operator/install-status Ensures that CNF Operators abide by best practices. The following is tested: 1. The Operator CSV reports "Installed" status. 2. The operator is not installed with privileged rights. Test passes if clusterPermissions is not present in the CSV manifest or is present with no resourceNames under its rules.
Result Type normative
Suggested Remediation Ensure that your Operator abides by the Operator Best Practices mentioned in the description.
Best Practice Reference CNF Best Practice V1.2 Section 6.2.12 and Section 6.3.3
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/platform-alteration/base-image ensures that the Container Base Image is not altered post-startup. This test is a heuristic, and ensures that there are no changes to the following directories: 1) /var/lib/rpm 2) /var/lib/dpkg 3) /bin 4) /sbin 5) /lib 6) /lib64 7) /usr/bin 8) /usr/sbin 9) /usr/lib 10) /usr/lib64
Result Type normative
Suggested Remediation Ensure that Container applications do not modify the Container Base Image. In particular, ensure that the following directories are not modified: 1) /var/lib/rpm 2) /var/lib/dpkg 3) /bin 4) /sbin 5) /lib 6) /lib64 7) /usr/bin 8) /usr/sbin 9) /usr/lib 10) /usr/lib64 Ensure that all required binaries are built directly into the container image, and are not installed post startup.
Best Practice Reference CNF Best Practice V1.2 Section 6.2.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/platform-alteration/boot-params tests that boot parameters are set through the MachineConfigOperator, and not set manually on the Node.
Result Type normative
Suggested Remediation Ensure that boot parameters are set directly through the MachineConfigOperator, or indirectly through the PerformanceAddonOperator. Boot parameters should not be changed directly through the Node, as OpenShift should manage the changes for you.
Best Practice Reference CNF Best Practice V1.2 Section 6.2.13 and 6.2.14
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/platform-alteration/hugepages-config checks to see that HugePage settings have been configured through MachineConfig, and not manually on the underlying Node. This test case applies only to Nodes that are configured with the "worker" MachineConfigSet. First, the "worker" MachineConfig is polled, and the Hugepage settings are extracted. Next, the underlying Nodes are polled for configured HugePages through inspection of /proc/meminfo. The results are compared, and the test passes only if they are the same.
Result Type normative
Suggested Remediation HugePage settings should be configured either directly through the MachineConfigOperator or indirectly using the PerformanceAddonOperator. This ensures that OpenShift is aware of the special MachineConfig requirements, and can provision your CNF on a Node that is part of the corresponding MachineConfigSet. Avoid making changes directly to an underlying Node, and let OpenShift handle the heavy lifting of configuring advanced settings.
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/platform-alteration/isredhat-release verifies if the container base image is redhat.
Result Type normative
Suggested Remediation build a new docker image that's based on UBI (redhat universal base image).
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/lifecycle/pod-recreation tests that no one has changed the node's sysctl configs after the node was created, the tests works by checking if the sysctl configs are consistent with the MachineConfig CR which defines how the node should be configured
Result Type normative
Suggested Remediation You should recreate the node or change the sysctls, recreating is recommended because there might be other unknown changes
Best Practice Reference CNF Best Practice V1.2 Section 6.2
Property Description
Version v1.0.0
Description http://test-network-function.com/testcases/platform-alteration/tainted-node-kernel ensures that the Node(s) hosting CNFs do not utilize tainted kernels. This test case is especially important to support Highly Available CNFs, since when a CNF is re-instantiated on a backup Node, that Node's kernel may not have the same hacks.'
Result Type normative
Suggested Remediation Test failure indicates that the underlying Node's' kernel is tainted. Ensure that you have not altered underlying Node(s) kernels in order to run the CNF.
Best Practice Reference CNF Best Practice V1.2 Section 6.2.14

Test Case Building Blocks Catalog

A number of Test Case Building Blocks, or tnf.Tests, are included out of the box. This is a summary of the available implementations:### http://test-network-function.com/tests/automountservice

Property Description
Version v1.0.0
Description check if automount service account token is set to false
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description Extracts OCP versions from the cluster
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to test ClusterRoleBindings of CNF pod's ServiceAccount.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used with any command and would match any output. The caller is responsible for interpreting the output and extracting data from it.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required
Property Description
Version v1.0.0
Description A container-specific test suite used to verify various aspects of the underlying container.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required jq, oc
Property Description
Version v1.0.0
Description Checks whether a give CRD has status subresource specification.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc, jq
Property Description
Version v1.0.0
Description extracts the csi driver info in the cluster
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to get node's /proc/cmdline
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required cat
Property Description
Version v1.0.0
Description check whether a given daemonset was deployed successfully
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to drain node from its deployment pods
Result Type normative
Intrusive true
Modifications Persist After Test true
Runtime Binaries Required jq, echo
Property Description
Version v1.0.0
Description A generic test used to read node names of pods owned by deployments in namespace
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc, grep
Property Description
Version v1.0.0
Description A test used to check if there were no installation during container runtime
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required grep, cut
Property Description
Version v1.0.0
Description A generic test used to determine if a target container/machine is based on RHEL.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required cat
Property Description
Version v1.0.0
Description A generic test used to extract the CNF pod's terminationGracePeriod.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required grep, cut
Property Description
Version v1.0.0
Description A generic test used to get node's next boot kernel args
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required ls, sort, head, cut, oc
Property Description
Version v1.0.0
Description A generic test used to get Image Pull Policy type.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to derive the default network interface IP address of a target container.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required ip
Property Description
Version v1.0.0
Description A test used to check logs are redirected to stderr/stdout
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc, wc
Property Description
Version v1.0.0
Description A generic test used to get an mc's kernel arguments
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc, jq, echo
Property Description
Version v1.0.0
Description A generic test used to uncordon a node
Result Type normative
Intrusive true
Modifications Persist After Test true
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to execute a command in a node
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc, echo
Property Description
Version v1.0.0
Description A generic test used to get a node's current mc
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc, grep
Property Description
Version v1.0.0
Description A generic test used to get node names
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to test services of CNF pod's namespace.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc, grep
Property Description
Version v1.0.0
Description Polls the state of the OpenShift cluster nodes using "oc get nodes -o json".
Result Type
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to verify a pod's nodeSelector and nodeAffinity configuration
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc, grep
Property Description
Version v1.0.0
Description A generic test used to test whether node is tainted
Result Type informative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc, cat, echo
Property Description
Version v1.0.0
Description An operator-specific test used to exercise the behavior of a given operator. In the current offering, we check if the operator ClusterServiceVersion (CSV) is installed properly. A CSV is a YAML manifest created from Operator metadata that assists the Operator Lifecycle Manager (OLM) in running the Operator.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required jq, oc
Property Description
Version v1.0.0
Description A test used to check the subscription of a given operator
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to verify pod is managed by a ReplicaSet/StatefulSet
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required cat
Property Description
Version v1.0.0
Description A generic test used to test ICMP connectivity from a source machine/container to a target destination.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required ping
Property Description
Version v1.0.0
Description A generic test used to get a pod's node
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to read namespace's deployments/statefulsets
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A generic test used to test RoleBindings of CNF pod's ServiceAccount.
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required cat, oc
Property Description
Version v1.0.0
Description A test to check the deployments scale in/out. The tests issues the oc scale command on a deployment for a given number of replicas and checks whether the command output is valid.
Result Type normative
Intrusive true
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A test used to check pre-stop lifecycle is defined
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc
Property Description
Version v1.0.0
Description A test used to find all sysctl configuration args
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required sysctl
Property Description
Version v1.0.0
Description A generic test used to get node's list of sysctl config files
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required cat
Property Description
Version v1.0.0
Description A generic test used to check pod's replica and podAntiAffinity configuration in high availability mode
Result Type normative
Intrusive false
Modifications Persist After Test false
Runtime Binaries Required oc