MENU
Contact
Contact

Cloud infrastructure end-to-end or conformance testing: What’s the difference

Picture of Sylwia Brant, Cloud Engineer

Sylwia Brant

Cloud Engineer
Nov 8, 2022|13 min read
Image Alt

How to evaluate cloud-native technology and build trust
3-1

1func TestJobPullFromACR(t *testing.T) {
2 f := features.New("Pull from ACR").
3 Setup(func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
4 var err error
5 ctx, err = createNSForTest(ctx, cfg, t)
6 require.NoError(t, err)
7 namespace := fmt.Sprint(ctx.Value(contextNamespaceNameKey))
8
9 t.Logf("Creating pod with testing image")
10 pod := buildPullACRImagePod(namespace)
11 assert.NoError(t, cfg.Client().Resources(namespace).Create(ctx, pod))
12
13 t.Logf("Pod %s/%s scheduled", namespace, podName)
14
15 return ctx
16 }).
17 Assess("Pull image from ACR", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
18 namespace := fmt.Sprint(ctx.Value(contextNamespaceNameKey))
19
20 pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: podName, Namespace: namespace}}
21 err := wait.For(conditions.New(cfg.Client().Resources()).PodRunning(pod), wait.WithImmediate(), wait.WithTimeout(time.Minute), wait.WithInterval(time.Second))
22 if assert.NoError(t, err) {
23 t.Logf("Pod reached phase 'Running'")
24 } else {
25 t.Logf("Pod didn't reach phase 'Running': %s", err.Error())
26 }
27
28 return ctx
29 }).Teardown(func(ctx context.Context, t *testing.T, config *envconf.Config) context.Context {
30 assert.NoError(t, deleteNSForTest(ctx, config, t))
31 return ctx
32 }).Feature()
33
34 testEnvironment.Test(t, f)
35}
36
37func buildPullACRImagePod(namespaceName string) *corev1.Pod {
38 acrName := buildAzureResourceNameWithoutHyphens("eun", "containerregistry")
39 return &corev1.Pod{
40 ObjectMeta: metav1.ObjectMeta{
41 Name: podName,
42 Namespace: namespaceName,
43 },
44 Spec: corev1.PodSpec{
45 Containers: []corev1.Container{
46 {
47 Name: "pull-from-acr-container",
48 Image: fmt.Sprintf("%s.azurecr.io/conformance-testing:latest", acrName),
49 },
50 },
51 },
52 }
53}
graphics

Subscribe to our newsletter and never miss an article