-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathport_parser_test.go
More file actions
110 lines (93 loc) · 3.29 KB
/
Copy pathport_parser_test.go
File metadata and controls
110 lines (93 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
Copyright 2023 The Fluid Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package jindocache
import (
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
"github.com/fluid-cloudnative/fluid/pkg/common"
"github.com/fluid-cloudnative/fluid/pkg/utils/fake"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
var cfg = `
[bigboot]
logger.dir = /dev/shm/default/oss-tf-dataset/bigboot/log
logger.cleanner.enable = true
[jindocache-common]
jfs.namespaces = spark
jfs.namespaces.spark.oss.uri = oss://tensorflow-datasets.oss-cn-shanghai-internal.aliyuncs.com/
namespace.backend.type = rocksdb
namespace.blocklet.cache.size = 1000000
namespace.filelet.cache.size = 100000
namespace.meta-dir = /dev/shm/default/oss-tf-dataset/bigboot/server
namespace.rpc.port = 18000
namespace.filelet.atime.enable = false
[jindocache-storage]
namespace.meta-dir = /dev/shm/default/oss-tf-dataset/bigboot/bignode
storage.data-dirs = /dev/shm/default/oss-tf-dataset/bigboot
storage.data-dirs.capacities = 10g
storage.ram.cache.size = 10g
storage.rpc.port = 18001
namespace.meta-dir = /dev/shm/default/oss-tf-dataset/bigboot/bignode
storage.compaction.enable = false
[jindocache-namespace]
client.oss.upload.queue.size = 5
client.oss.upload.threads = 4
client.storage.rpc.port = 18001
`
var _ = Describe("parsePortsFromConfigMap", func() {
It("should parse ports from configMap", func() {
configMap := &v1.ConfigMap{
Data: map[string]string{
"jindocache.cfg": cfg,
},
}
gotPorts, err := parsePortsFromConfigMap(configMap)
Expect(err).NotTo(HaveOccurred())
Expect(gotPorts).To(Equal([]int{18000, 18001}))
})
It("should collect reserved ports from jindo runtime configmaps", func() {
dataset := &datav1alpha1.Dataset{
ObjectMeta: metav1.ObjectMeta{Name: "spark", Namespace: "fluid"},
Status: datav1alpha1.DatasetStatus{
Runtimes: []datav1alpha1.Runtime{{
Category: common.AccelerateCategory,
Name: "spark",
Namespace: "fluid",
Type: "jindo",
}},
},
}
nonJindoDataset := &datav1alpha1.Dataset{
ObjectMeta: metav1.ObjectMeta{Name: "other", Namespace: "fluid"},
Status: datav1alpha1.DatasetStatus{
Runtimes: []datav1alpha1.Runtime{{
Name: "other",
Namespace: "fluid",
Type: "alluxio",
}},
},
}
configMap := &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{Name: "spark-jindofs-config", Namespace: "fluid"},
Data: map[string]string{"jindocache.cfg": cfg},
}
objects := []runtime.Object{dataset, nonJindoDataset, configMap}
fakeClient := fake.NewFakeClientWithScheme(testScheme, objects...)
ports, err := GetReservedPorts(fakeClient)
Expect(err).NotTo(HaveOccurred())
Expect(ports).To(Equal([]int{18000, 18001}))
})
})