@@ -33,6 +33,14 @@ type StartOpts struct {
33
33
// InitScript is a Lua script for tarantool to run on start.
34
34
InitScript string
35
35
36
+ // ConfigFile is a path to a configuration file for a Tarantool instance.
37
+ // Required in pair with InstanceName.
38
+ ConfigFile string
39
+
40
+ // InstanceName is a name of an instance to run.
41
+ // Required in pair with ConfigFile.
42
+ InstanceName string
43
+
36
44
// Listen is box.cfg listen parameter for tarantool.
37
45
// Use this address to connect to tarantool after configuration.
38
46
// https://www.tarantool.io/en/doc/latest/reference/configuration/#cfg-basic-listen
@@ -108,7 +116,7 @@ var (
108
116
)
109
117
110
118
func init () {
111
- tarantoolVersionRegexp = regexp .MustCompile (`Tarantool (?: Enterprise )?(\d+)\.(\d+)\.(\d+).*` )
119
+ tarantoolVersionRegexp = regexp .MustCompile (`Tarantool (Enterprise )?(\d+)\.(\d+)\.(\d+).*` )
112
120
}
113
121
114
122
// atoiUint64 parses string to uint64.
@@ -145,15 +153,58 @@ func IsTarantoolVersionLess(majorMin uint64, minorMin uint64, patchMin uint64) (
145
153
return true , fmt .Errorf ("failed to parse output %q" , out )
146
154
}
147
155
148
- if major , err = atoiUint64 (parsed [1 ]); err != nil {
156
+ if major , err = atoiUint64 (parsed [2 ]); err != nil {
149
157
return true , fmt .Errorf ("failed to parse major from output %q: %w" , out , err )
150
158
}
151
159
152
- if minor , err = atoiUint64 (parsed [2 ]); err != nil {
160
+ if minor , err = atoiUint64 (parsed [3 ]); err != nil {
153
161
return true , fmt .Errorf ("failed to parse minor from output %q: %w" , out , err )
154
162
}
155
163
156
- if patch , err = atoiUint64 (parsed [3 ]); err != nil {
164
+ if patch , err = atoiUint64 (parsed [4 ]); err != nil {
165
+ return true , fmt .Errorf ("failed to parse patch from output %q: %w" , out , err )
166
+ }
167
+
168
+ if major != majorMin {
169
+ return major < majorMin , nil
170
+ } else if minor != minorMin {
171
+ return minor < minorMin , nil
172
+ } else {
173
+ return patch < patchMin , nil
174
+ }
175
+ }
176
+
177
+ // IsTarantoolEEVersionLess checks if tarantool is Enterprise and version is less
178
+ // than passed <major.minor.patch>. Returns error if failed
179
+ // to extract version.
180
+ func IsTarantoolEEVersionLess (majorMin uint64 , minorMin uint64 , patchMin uint64 ) (bool , error ) {
181
+ var major , minor , patch uint64
182
+
183
+ out , err := exec .Command (getTarantoolExec (), "--version" ).Output ()
184
+
185
+ if err != nil {
186
+ return true , err
187
+ }
188
+
189
+ parsed := tarantoolVersionRegexp .FindStringSubmatch (string (out ))
190
+
191
+ if parsed == nil {
192
+ return true , fmt .Errorf ("failed to parse output %q" , out )
193
+ }
194
+
195
+ if parsed [1 ] == "" {
196
+ return true , nil
197
+ }
198
+
199
+ if major , err = atoiUint64 (parsed [2 ]); err != nil {
200
+ return true , fmt .Errorf ("failed to parse major from output %q: %w" , out , err )
201
+ }
202
+
203
+ if minor , err = atoiUint64 (parsed [3 ]); err != nil {
204
+ return true , fmt .Errorf ("failed to parse minor from output %q: %w" , out , err )
205
+ }
206
+
207
+ if patch , err = atoiUint64 (parsed [4 ]); err != nil {
157
208
return true , fmt .Errorf ("failed to parse patch from output %q: %w" , out , err )
158
209
}
159
210
@@ -219,6 +270,11 @@ func StartTarantool(startOpts StartOpts) (TarantoolInstance, error) {
219
270
fmt .Sprintf ("TEST_TNT_MEMTX_USE_MVCC_ENGINE=%t" , startOpts .MemtxUseMvccEngine ),
220
271
fmt .Sprintf ("TEST_TNT_AUTH_TYPE=%s" , startOpts .Auth ),
221
272
)
273
+ if startOpts .ConfigFile != "" && startOpts .InstanceName != "" {
274
+ inst .Cmd .Env = append (inst .Cmd .Env , fmt .Sprintf ("TT_CONFIG=%s" , startOpts .ConfigFile ))
275
+ inst .Cmd .Env = append (inst .Cmd .Env ,
276
+ fmt .Sprintf ("TT_INSTANCE_NAME=%s" , startOpts .InstanceName ))
277
+ }
222
278
223
279
// Copy SSL certificates.
224
280
if startOpts .SslCertsDir != "" {
0 commit comments