Anka Packer Builder – To create macOS Anka VMs for iOS/macOS CI

Thanks to Lachlan Donald, there is now a Packer Builder for Anka. The Anka Packer builder is able to create macOS Anka VMs starting from a macOS installer app.

The builder builds a fully functional macOS VM from scratch, provisioned with Anka PV network and block drivers for near native build and test performance. You can configure CPU cores, RAM and Disk size. Quickly setup your Anka VM and then use ‘anka run’ to configure it with your dependencies.

Download it from GitHub. Packer Builder for macOS Anka VM

Refer to Anka documentation to create macOS Anka VMs from “*.dmg” or “*.iso”.

Anka Build Terminology – Components to setup on-premise iOS CI infrastructure

Anka Build is macOS native virtualization platform from Veertu. It’s a complete platform to implement and manage macOS VMs on a large scale for iOS CI. Anka Build includes lightweight Anka client, which is the native hypervisor to run macOS VMs on Mac hardware, the Controller, which is used to on-demand provision and manage macOS VMs and the Registry, which is used to store and distribute macOS VM templates for CI.

While Anka Build manages macOS VMs on a large scale for CI, all Anka Build modules by themselves are very lightweight, easy to deploy and manage.

iOS Ci with Anka Build

Anka Client

Anka client is a very lightweight mac application. Unlike, other server virtualization solutions for mac hardware, Anka Build doesn’t strip away the core macOS. Anka Build runs as another mac application on the mac hardware and enables the creation and running of macOS VMs. Anka Build macOS VMs are very responsive and perform at near native speed. These Anka VMs are used as on-demand build and test environments for iOS/macOS CI.

Anka Controller

Anka Controller module is packaged as a docker container. The Controller provides a single interface through its REST APIs to on-demand provision macOS VMs, requested by CI jobs. Think of it as central management for your Anka Build Cloud.

Anka Registry

Anka Registry module is used to store and distribute different versions of macOS VMs. Anka Registry is also packaged in a Docker container. A iOS/macOS CI job can request X quantity of N type of macOS VM. When Controller receives this request, it pulls N macOS VM (version tag) from the registry and spins up X quantity of these VMs using Anka Client on your Anka nodes. Anka Controller also maintains a queue of all incoming requests from the CI system and manages them.

Anka Node

Anka node is one or many Mac hardware on which you want to run your iOS CI jobs. You install Anka Build client on each of your Anka Build Nodes and then connect the nodes to the Anka Controller.

Connecting Anka Build to your CI system

While Anka Build platform consists of multiple modules, you only need to integrate your CI system to Anka Build Controller in order to start using Anka Build for executing iOS CI jobs. Anka Build Controller exposes REST APIs, through which you can integrate your existing CI system.

For Jenkins based CI implementation, there is a Jenkins plugin available, which can be used to very easily set up integration with Anka Build iOS cloud infrastructure.

Performance and Scalability in virtualized iOS build and test infrastructure

Growth is good, and when development teams grow, often, they find themselves having to choose between performance and scalability factors related to their development process. Most often, iOS application development project start by consuming hosted service offerings for their build and test processes. Then, as growth happens, team size increases, the velocity of code commits increase significantly, the number of projects increase, and soon performance issues like long queue wait times and longer build and test times start to creep up.

In most scenarios, one can throw more resources at this problem to address the issue. However, in the macOS world, that’s not the case. While scalable and high-performing platforms like AWS, Google Cloud, Azure which are powered by virtualization exist for Linux and Windows, nothing similar exists for macOS. All existing approaches to virtualization of macOS suffer from a tradeoff between scalability and performance.

Veertu Anka hypervisor eliminates the need for the user to make this tradeoff. Anka Build, powered by Anka hypervisor, enables growing iOS development teams to very easily, setup and configure a scalable and high performing AWS like private cloud for iOS build and test.

There is a lot of skepticism around the performance of iOS simulator test jobs on virtualized infrastructure, especially as the test portfolio expands. Anka Build addresses this for its users with a combination of three variables. – The performance of Anka VM, Time to provision an on-demand VM and VMs in Anka registry with pre-boot iOS simulator.

Anka VMs run on top of Anka Hypervisor, which is a new lightweight virtualization technology that leverages the macOS Hypervisor.framework to run macOS VMs in the most resource efficient manner. Instead of directly requesting and managing macOS resources like CPU or memory for the VMs, Anka Hypervisor, through the macOS Hypervisor.framework, lets the operating system manage the VM resource needs in the same way it runs other applications. As a result, Anka VMs perform much faster and are more responsive. Anka VMs are also packaged with a para-virtual block and network drivers, to enable faster execution of build and test jobs.

Time to provision or the time it takes to have an environment ready for the iOS build and test job is a significant factor that impacts overall performance. Anka Build addresses this with ‘Instant Start’ feature. ‘Instant Start’ offers on-demand provisioned instances instantaneously (1-2 sec) to execute the iOS Ci jobs.

iOS simulator UI test job performance on dedicated or virtualized hardware is impacted by, the long boot time of iOS Simulator. With Anka Build, DevOps can address this problem by pre-booting the simulator in the VM for each device type and pushing the VM to Anka registry. Then, CI UI test jobs, through Anka controller can on-demand provision instances from these VMs and use the pre-booted iOS simulator at full throttle. Each test is run in a clean, sterilized environment with pre-booted simulator of a particular device type.

In our internal tests, we have recorded that iOS simulator UI tests performed with Anka Build and pre-booted simulator VMs take less time than when running on dedicated hardware.

                                         

iOS simulator test in Anka VM



               

iOS simulator test on dedicated hardware

Building a private iOS Device Cloud

Now that you have Anka Build up and running for your iOS CI infrastructure, your developers are more productive and your environment is easier to manage. But how do you test your iOS app releases on multiple iOS devices to make sure they are rendering properly?

Anka Build enables you to execute tests on real devices, in the same way as your simulator-based test workflow. Cable your physical devices to your Anka Build macOS private cloud nodes, then connect them at run time to on-demand macOS VMs and run your tests. Using Anka, you can manage a single device or a group of similar devices through a simple command line interface.

What are the benefits of this approach?
  1. One single scalable iOS infrastructure for build, simulator based tests and real device tests.
  2. Eliminates the need to separately manage mac hardware connected to real devices for CI.
  3. Management of real devices through a simple, command line interface.


Check out the following example of making a real device available on-demand for testing:

Step 1 – Create a VM to be used for real device testing

Step 2 –  Let’s say you need to run multiple tests on multiple ipad models. Create a USB-group called ipadgrp:

`anka usb-group create ipadgrp`

Step 3 – Add all of your ipad models to this group:

`anka usb-group add-device <device identifier1> ipadgrp`

`anka usb-group add-device <device identifier 2> ipadgrp`

Step 4 – Attach this usb-group to the previously created VM:

`anka modify VM add sub-group ipadgrp`

Step 5 – Configure your specific CI job to use this VM for real device testing.

Step 6 – Use Anka Controller to spin up on-demand instances of this VM. Each VM instance at run time will claim an available ipad device from the `ipadgrp` and make it available for testing.

Additional documentation on this feature is available at using real devices with Anka Build.