Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Support list/get/delete of nested objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Jun 23, 2022
1 parent 6ef8ce8 commit 0fc9a2a
Show file tree
Hide file tree
Showing 51 changed files with 674 additions and 434 deletions.
14 changes: 9 additions & 5 deletions integration/client/apps_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package client

import (
"strings"
"testing"

"github.com/acorn-io/acorn/integration/helper"
apiv1 "github.com/acorn-io/acorn/pkg/apis/api.acorn.io/v1"
v1 "github.com/acorn-io/acorn/pkg/apis/internal.acorn.io/v1"
"github.com/acorn-io/acorn/pkg/client"
kclient "github.com/acorn-io/acorn/pkg/k8sclient"
"github.com/acorn-io/acorn/pkg/labels"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/api/resource"
)
Expand Down Expand Up @@ -242,9 +244,11 @@ func TestAppUpdate(t *testing.T) {
}, thirdApp.Annotations)

assert.Equal(t, map[string]string{
"label1": "val1",
"label2": "val3",
"label3": "val3",
"label1": "val1",
"label2": "val3",
"label3": "val3",
labels.AcornRootNamespace: c.GetNamespace(),
labels.AcornManaged: "true",
}, thirdApp.Labels)

assert.Equal(t, []v1.EndpointBinding{
Expand Down Expand Up @@ -414,8 +418,8 @@ func TestAppLog(t *testing.T) {

assert.Equal(t, "", msg1.Error)
assert.Equal(t, "", msg2.Error)
assert.Equal(t, "default", msg1.ContainerName)
assert.Equal(t, "default", msg2.ContainerName)
assert.True(t, strings.HasPrefix(msg1.ContainerName, "default-"))
assert.True(t, strings.HasPrefix(msg2.ContainerName, "default-"))
assert.NotEqual(t, "", msg1.Line)
assert.NotEqual(t, "", msg1.Line)

Expand Down
5 changes: 5 additions & 0 deletions integration/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/acorn-io/acorn/pkg/build"
hclient "github.com/acorn-io/acorn/pkg/client"
kclient "github.com/acorn-io/acorn/pkg/k8sclient"
"github.com/acorn-io/acorn/pkg/labels"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -55,6 +56,10 @@ func TestFriendlyNameInContainer(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
GenerateName: "simple-app",
Namespace: ns.Name,
Labels: map[string]string{
labels.AcornRootNamespace: ns.Name,
labels.AcornManaged: "true",
},
},
Spec: v1.AppInstanceSpec{
Image: image.ID,
Expand Down
23 changes: 1 addition & 22 deletions integration/client/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
apiv1 "github.com/acorn-io/acorn/pkg/apis/api.acorn.io/v1"
"github.com/acorn-io/acorn/pkg/client"
kclient "github.com/acorn-io/acorn/pkg/k8sclient"
"github.com/acorn-io/acorn/pkg/namespace"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
)
Expand Down Expand Up @@ -78,11 +77,6 @@ func TestContainerDelete(t *testing.T) {
return app.Status.Namespace != "" && app.Status.ContainerStatus["default"].UpToDate == 1
})

helper.WaitForObject(t, kclient.Watch, &corev1.NamespaceList{}, ns, func(ns *corev1.Namespace) bool {
m, _ := namespace.Children(ns)
return len(m) > 0
})

cons, err := c.ContainerReplicaList(ctx, nil)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -131,11 +125,6 @@ func TestContainerGet(t *testing.T) {
return app.Status.ContainerStatus["default"].UpToDate == 1
})

helper.WaitForObject(t, kclient.Watch, &corev1.NamespaceList{}, ns, func(ns *corev1.Namespace) bool {
m, _ := namespace.Children(ns)
return len(m) > 0
})

cons, err := c.ContainerReplicaList(ctx, nil)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -177,12 +166,7 @@ func TestContainerExec(t *testing.T) {
}

helper.WaitForObject(t, lclient.Watch, &apiv1.AppList{}, app, func(app *apiv1.App) bool {
return app.Status.Namespace != ""
})

helper.WaitForObject(t, kclient.Watch, &corev1.NamespaceList{}, ns, func(ns *corev1.Namespace) bool {
m, _ := namespace.Children(ns)
return len(m) > 0
return app.Status.ContainerStatus["default"].UpToDate > 0
})

cons, err := c.ContainerReplicaList(ctx, nil)
Expand Down Expand Up @@ -239,11 +223,6 @@ func TestContainerDebugExec(t *testing.T) {
return app.Status.Namespace != "" && app.Status.ContainerStatus["default"].UpToDate > 0
})

helper.WaitForObject(t, kclient.Watch, &corev1.NamespaceList{}, ns, func(ns *corev1.Namespace) bool {
m, _ := namespace.Children(ns)
return len(m) > 0
})

cons, err := c.ContainerReplicaList(ctx, nil)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 0fc9a2a

Please sign in to comment.