func (a *AppControllerManager) BeforeEach() {
	var err error
	a.Clientset, err = KubeClient()
	Expect(err).NotTo(HaveOccurred())
	AddServiceAccountToAdmins(a.Clientset)
	By("Creating namespace and initializing test framework")
	namespaceObj := &v1.Namespace{
		ObjectMeta: v1.ObjectMeta{
			GenerateName: "e2e-tests-ac-",
			Namespace:    "",
		},
		Status: v1.NamespaceStatus{},
	}
	a.Namespace, err = a.Clientset.Namespaces().Create(namespaceObj)
	Expect(err).NotTo(HaveOccurred())
	By("Creating AC client with namespace " + a.Namespace.Name)
	a.Client, err = GetAcClient(a.Namespace.Name)
	Expect(err).NotTo(HaveOccurred())
	By("Deploying appcontroller image")
	a.Prepare()
}
BeforeEach is an action executed before each test
package utils
import (
	"time"
	"github.com/Mirantis/k8s-AppController/pkg/client"
	"github.com/Mirantis/k8s-AppController/pkg/interfaces"
	"github.com/Mirantis/k8s-AppController/pkg/scheduler"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/pkg/api"
	"k8s.io/client-go/pkg/api/errors"
	"k8s.io/client-go/pkg/api/v1"
)
const (
	appcontrollerPod = "k8s-appcontroller"
)
type AppControllerManager struct {
	Client    client.Interface
	Clientset *kubernetes.Clientset
	ns        string
	Namespace *v1.Namespace
	acPod *v1.Pod
}
func (a *AppControllerManager) Run() string {
	return a.RunWithOptions(interfaces.DependencyGraphOptions{MinReplicaCount: 1})
}
func (a *AppControllerManager) RunWithOptions(options interfaces.DependencyGraphOptions) string {
	sched := scheduler.New(a.Client, nil, 0)
	task, err := scheduler.Deploy(sched, options, false, nil)
	Expect(err).NotTo(HaveOccurred())
	return task
}
func (a *AppControllerManager) DeleteAppControllerPod() {
	By("Removing pod  " + appcontrollerPod)
	err := a.Client.Pods().Delete(appcontrollerPod, nil)
	Expect(err).NotTo(HaveOccurred())
	Eventually(func() bool {
		_, err := a.Client.Pods().Get(appcontrollerPod)
		return errors.IsNotFound(err)
	}, 20*time.Second, 1*time.Second).Should(BeTrue(), "Appcontroller pod wasn't removed in time")
}
func (a *AppControllerManager) Prepare() {
	appControllerObj := &v1.Pod{
		ObjectMeta: v1.ObjectMeta{
			Name: appcontrollerPod,
			Annotations: map[string]string{
				"pod.alpha.kubernetes.io/init-containers": `[{"name": "kubeac-bootstrap", "image": "mirantis/k8s-appcontroller", "imagePullPolicy": "Never", "command": ["kubeac", "bootstrap", "/opt/kubeac/manifests"]}]`,
			},
		},
		Spec: v1.PodSpec{
			RestartPolicy: "Always",
			Containers: []v1.Container{
				{
					Name:            "kubeac",
					Image:           "mirantis/k8s-appcontroller",
					Command:         []string{"kubeac", "deploy"},
					ImagePullPolicy: v1.PullNever,
					Env: []v1.EnvVar{
						{
							Name:  "KUBERNETES_AC_LABEL_SELECTOR",
							Value: "",
						},
						{
							Name:  "KUBERNETES_AC_POD_NAMESPACE",
							Value: a.Namespace.Name,
						},
					},
				},
			},
		},
	}
	var err error
	a.acPod, err = a.Clientset.Pods(a.Namespace.Name).Create(appControllerObj)
	Expect(err).NotTo(HaveOccurred())
	WaitForPod(a.Clientset, a.Namespace.Name, a.acPod.Name, v1.PodRunning)
	Eventually(func() bool {
		_, depsErr := a.Client.ResourceDefinitions().List(api.ListOptions{})
		_, defsErr := a.Client.Dependencies().List(api.ListOptions{})
		return defsErr == nil && depsErr == nil
	}, 120*time.Second, 5*time.Second).Should(BeTrue())
}