Skip to content

Commit cfcd580

Browse files
author
Diego Alfonso
committed
chore: Add test for source updated
Signed-off-by: Diego Alfonso <[email protected]>
1 parent e3d753b commit cfcd580

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2023 VMware, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: carto.run/v1alpha1
16+
kind: Workload
17+
metadata:
18+
annotations:
19+
local-source-proxy.apps.tanzu.vmware.com: :default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69
20+
labels:
21+
apps.tanzu.vmware.com/workload-type: web
22+
name: my-workload
23+
namespace: default
24+
spec:
25+
params:
26+
- name: annotations
27+
value:
28+
autoscaling.knative.dev/minScale: "2"
29+
source:
30+
image: :default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69
31+
subPath: new-subpath

pkg/commands/workload_apply_test.go

+70
Original file line numberDiff line numberDiff line change
@@ -8909,6 +8909,76 @@ To get status: "tanzu apps workload get my-workload"
89098909
}
89108910
},
89118911
},
8912+
{
8913+
Name: "update from local source using lsp changing subpath",
8914+
Skip: runtm.GOOS == "windows",
8915+
Args: []string{workloadName, flags.LocalPathFlagName, localSource, flags.FilePathFlagName, "./testdata/workload-LSP-subPath.yaml", flags.YesFlagName},
8916+
GivenObjects: []client.Object{
8917+
parent.
8918+
MetadataDie(func(d *diemetav1.ObjectMetaDie) {
8919+
d.Annotations(map[string]string{apis.LocalSourceProxyAnnotationName: ":default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69"})
8920+
d.Labels(map[string]string{apis.WorkloadTypeLabelName: "web"})
8921+
}).SpecDie(func(d *diecartov1alpha1.WorkloadSpecDie) {
8922+
d.Source(&cartov1alpha1.Source{
8923+
Image: ":default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69",
8924+
Subpath: "old-subpath",
8925+
})
8926+
}),
8927+
},
8928+
KubeConfigTransport: clitesting.NewFakeTransportFromResponse(respCreator(http.StatusOK, `{"statuscode": "200", "message": "any ignored message"}`, myWorkloadHeader)),
8929+
ExpectUpdates: []client.Object{
8930+
&cartov1alpha1.Workload{
8931+
ObjectMeta: metav1.ObjectMeta{
8932+
Namespace: defaultNamespace,
8933+
Name: workloadName,
8934+
Labels: map[string]string{
8935+
apis.WorkloadTypeLabelName: "web",
8936+
},
8937+
Annotations: map[string]string{
8938+
"local-source-proxy.apps.tanzu.vmware.com": ":default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69",
8939+
},
8940+
},
8941+
Spec: cartov1alpha1.WorkloadSpec{
8942+
Source: &cartov1alpha1.Source{
8943+
Image: ":default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69",
8944+
Subpath: "new-subpath",
8945+
},
8946+
Params: []cartov1alpha1.Param{
8947+
{
8948+
Name: "annotations",
8949+
Value: apiextensionsv1.JSON{Raw: []byte(`{"autoscaling.knative.dev/minScale":"2"}`)},
8950+
},
8951+
},
8952+
},
8953+
},
8954+
},
8955+
ExpectOutput: fmt.Sprintf(`
8956+
❗ WARNING: Configuration file update strategy is changing. By default, provided configuration files will replace rather than merge existing configuration. The change will take place in the January 2024 TAP release (use "--update-strategy" to control strategy explicitly).
8957+
8958+
Publishing source in "%s" to "local-source-proxy.tap-local-source-system.svc.cluster.local/source:default-my-workload"...
8959+
No source code is changed
8960+
8961+
🔎 Update workload:
8962+
...
8963+
8, 8 | apps.tanzu.vmware.com/workload-type: web
8964+
9, 9 | name: my-workload
8965+
10, 10 | namespace: default
8966+
11, 11 |spec:
8967+
12 + | params:
8968+
13 + | - name: annotations
8969+
14 + | value:
8970+
15 + | autoscaling.knative.dev/minScale: "2"
8971+
12, 16 | source:
8972+
13, 17 | image: :default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69
8973+
14 - | subPath: old-subpath
8974+
18 + | subPath: new-subpath
8975+
👍 Updated workload "my-workload"
8976+
8977+
To see logs: "tanzu apps workload tail my-workload --timestamp --since 1h"
8978+
To get status: "tanzu apps workload get my-workload"
8979+
8980+
`, localSource),
8981+
},
89128982
}
89138983

89148984
table.Run(t, scheme, func(ctx context.Context, c *cli.Config) *cobra.Command {

0 commit comments

Comments
 (0)