@@ -33,6 +33,14 @@ type StartOpts struct {
3333 // InitScript is a Lua script for tarantool to run on start.
3434 InitScript string
3535
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+
3644 // Listen is box.cfg listen parameter for tarantool.
3745 // Use this address to connect to tarantool after configuration.
3846 // https://www.tarantool.io/en/doc/latest/reference/configuration/#cfg-basic-listen
@@ -108,7 +116,7 @@ var (
108116)
109117
110118func init () {
111- tarantoolVersionRegexp = regexp .MustCompile (`Tarantool (?: Enterprise )?(\d+)\.(\d+)\.(\d+).*` )
119+ tarantoolVersionRegexp = regexp .MustCompile (`Tarantool (Enterprise )?(\d+)\.(\d+)\.(\d+).*` )
112120}
113121
114122// atoiUint64 parses string to uint64.
@@ -145,15 +153,58 @@ func IsTarantoolVersionLess(majorMin uint64, minorMin uint64, patchMin uint64) (
145153 return true , fmt .Errorf ("failed to parse output %q" , out )
146154 }
147155
148- if major , err = atoiUint64 (parsed [1 ]); err != nil {
156+ if major , err = atoiUint64 (parsed [2 ]); err != nil {
149157 return true , fmt .Errorf ("failed to parse major from output %q: %w" , out , err )
150158 }
151159
152- if minor , err = atoiUint64 (parsed [2 ]); err != nil {
160+ if minor , err = atoiUint64 (parsed [3 ]); err != nil {
153161 return true , fmt .Errorf ("failed to parse minor from output %q: %w" , out , err )
154162 }
155163
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 {
157208 return true , fmt .Errorf ("failed to parse patch from output %q: %w" , out , err )
158209 }
159210
@@ -219,6 +270,11 @@ func StartTarantool(startOpts StartOpts) (TarantoolInstance, error) {
219270 fmt .Sprintf ("TEST_TNT_MEMTX_USE_MVCC_ENGINE=%t" , startOpts .MemtxUseMvccEngine ),
220271 fmt .Sprintf ("TEST_TNT_AUTH_TYPE=%s" , startOpts .Auth ),
221272 )
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+ }
222278
223279 // Copy SSL certificates.
224280 if startOpts .SslCertsDir != "" {
0 commit comments