A Go-based utility for managing tests related to Virtual Machines (VMs), services, network policies, and routes on OpenShift clusters. This project provides a framework for creating, deploying, and managing VMs, pods, and other resources using Kubernetes and KubeVirt, while also offering network and route testing capabilities.
This project provides a utility to simplify:
- Creating and managing VMs on KubeVirt using predefined templates.
- Testing network policies, services (ClusterIP, LoadBalancer), and routes.
- Running tests using multiple namespaces.
Ensure you have the following installed:
- Go (v1.16+)
- Kubernetes cluster with KubeVirt and OpenShift installed.
- Access to a KubeVirt-enabled cluster with the required permissions.
- Git for version control.
kubeconfig: Ensure that your kubeconfig file is accessible for authentication.- Access to OpenShift and KubeVirt APIs for VM and network testing.
-
Clone the repository:
git clone https://github.com/dror1212/openshift-tests-util.git cd openshift-tests-util -
Install dependencies: Ensure that the Go modules are installed:
go mod tidy
-
Set up KubeConfig:
- Ensure that your
kubeconfigis set up and that you have the necessary access to interact with the Kubernetes API. - You can specify your
KUBECONFIGenvironment variable if needed:export KUBECONFIG=/path/to/your/kubeconfig
- Ensure that your
To run specific tests or use utilities from the framework, follow the instructions below.
- Run tests:
To run tests, use the Ginkgo test suite (default testing framework):
ginkgo -r --focus "<Test Name>"
util/: Contains utility files like:- VM creation logic (
vm.go) - Pod management (
pod.go) - Network policy handling (
networkPolicy.go) - Route creation and handling (
route.go)
- VM creation logic (
framework/: Contains higher-level test helpers, such as:pod_actions.gofor pod-related test utilities.service_actions.gofor service creation and management.route_actions.gofor managing OpenShift routes in tests.test_context.gofor managing reusable test context (namespace, clients, etc.).
tests/: Contains Ginkgo-based test cases, including:network/cluster_ip_test.go: Tests for ClusterIP service access.network/network_policy_test.go: Tests for NetworkPolicy restrictions and access.network/route_test.go: Tests for routes in OpenShift.
consts/: Holds constant variables such as default memory, namespace settings, and more.
Default settings like CPU, memory, and namespaces can be configured in the consts/constants.go file.
To adjust cloud-init scripts or custom startup scripts, modify or add new shell scripts to the scripts/ directory.
To run tests, you can utilize the Ginkgo test suite. For example running all the network relating tests:
ginkgo -v tests/network/Each test is designed to validate the functionality of OpenShift/Kubernetes components in an isolated environment using test helpers from the framework package.