istio.io/istio@v0.0.0-20240520182934-d79c90f27776/tests/integration/pilot/README.md (about) 1 # Writing Tests for VMs 2 3 This document describes the integration and extension mechanisms to exercise VM related code. 4 The primary goals are to: 5 1. Test VM-related Istio code so that newly submitted commits won't break VM support 6 1. Ensure the code works on a range of supported OS types and versions. 7 8 **Note: We currently use mock/simulated VMs for testing purposes. In the future, the testing might switch 9 to utilize actual compute instances from different providers.** 10 11 ## Overview 12 13 Scenarios in which one might want to add a VM test in this doc: 14 1. Testing existing core Istio features such as traffic management, security, telemetry, etc. for **VMs** 15 1. Supporting new OS images for VMs 16 1. Testing onboarding tools (iptables, certs, istio-sidecar, etc.) and workflows (services, DNS, etc.) to enmesh a VM 17 18 ## Secenario 1: Testing VM-related Istio Code 19 20 Most integration tests in Istio use the Echo application. To test connectivity, security and telemetry for a VM 21 in the mesh, we deploy an instance of the Echo application as a VM resource. A VM Echo instance will simulate a VM, 22 disabling kube-dns, Service Account mount, etc. For more information around VM onboarding, 23 refer to this [doc](https://istio.io/latest/docs/setup/install/virtual-machine/). 24 25 To deploy an echo instance as a VM 26 1. Set the ports for the VMs. 27 1. Set `DeployAsVm` to be true in `echo.Config`. 28 We used DefaultVMImage in the example. 29 30 For example, 31 32 ```go 33 ports := []echo.Port{ 34 { 35 Name: "http", 36 Protocol: protocol.HTTP, 37 InstancePort: 8090, 38 ServicePort: 8090, 39 }, 40 } 41 echo.Config{ 42 Service: "vm", 43 Namespace: "virtual-machine", 44 Ports: ports, 45 Pilot: p, 46 DeployAsVM: true, 47 VMImage: vm.DefaultVMImage 48 } 49 ``` 50 51 The default image referenced with `DefaultVMImage` from `vm` package should be used for all pre-submit tests since 52 this is the only image available in the pre-submit stage. Using additional images are only possible in 53 post-submit tests as shown in the [next section](#scenario-2-supporting-additional-os-images ). 54 A complete list of supported additional images can be found in [`vm_test.go`](https://github.com/istio/istio/blob/master/tests/integration/pilot/vm_test.go). 55 If `VMImage` is not provided while `DeployAsVM` is on, it will default the Docker image to be `DefaultVMImage`. 56 57 ## Scenario 2: Supporting Additional OS Images 58 59 We list the supported OSes in [vm_test.go](https://github.com/istio/istio/blob/master/tests/integration/pilot/vm_test.go) 60 and the images will be created in [prow/lib.sh](https://github.com/istio/istio/blob/master/prow/lib.sh). 61 62 To add additional supported images for testing: 63 1. Modify [tools/istio-docker.mk](https://github.com/istio/istio/blob/master/tools/istio-docker.mk) to add more 64 build targets. Specify the OS image name and version in the Makefile, and it will be passed to the Dockerfile. 65 See other build targets for references. 66 1. Modify `prow/lib.sh` by adding images to the targets to build images for CI/CD. 67 1. Add the images to `util.go` to be tested in PostSubmit jobs. 68 1. (Optional) Modify the `DefaultVMImage` in `util.go` in case the default supported image changes. 69 70 **Note: We will only build default image for pre-submit jobs and build all others for post-submit jobs 71 to save time in CI/CD.** 72 73 ## Scenario 3: Testing VM Onboarding & Enmeshing 74 75 Detailed steps to onboard a VM could be found in [VM onboarding documentation](https://istio.io/latest/docs/setup/install/virtual-machine/). 76 77 Currently, these steps are pre-configured and built in the deployment. However, each of them could be tested 78 by tweaking the [VM deployment template](https://github.com/istio/istio/blob/master/pkg/test/framework/components/echo/kube/deployment.go#L193).