@@ -41,7 +41,7 @@ protected KurrentPermanentFixture(ConfigureFixture configure) {
41
41
public KurrentFixtureOptions Options { get ; }
42
42
public Faker Faker { get ; } = new Faker ( ) ;
43
43
44
- // public Version EventStoreVersion { get; private set; } = null!;
44
+ public Version EventStoreVersion { get ; private set ; } = null ! ;
45
45
public bool EventStoreHasLastStreamPosition { get ; private set ; }
46
46
47
47
public KurrentClient Streams { get ; private set ; } = null ! ;
@@ -87,9 +87,9 @@ public async Task InitializeAsync() {
87
87
await ContainerSemaphore . WaitAsync ( ) ;
88
88
try {
89
89
await Service . Start ( ) ;
90
- // EventStoreVersion = GetEventStoreVersion();
91
- // EventStoreHasLastStreamPosition = (EventStoreVersion?.Major ?? int.MaxValue) >= 21;
92
- EventStoreHasLastStreamPosition = true ;
90
+ EventStoreVersion = GetEventStoreVersion ( ) ;
91
+ EventStoreHasLastStreamPosition = ( EventStoreVersion ? . Major ?? int . MaxValue ) >= 21 ;
92
+ // EventStoreHasLastStreamPosition = true;
93
93
} finally {
94
94
ContainerSemaphore . Release ( ) ;
95
95
}
@@ -133,36 +133,38 @@ async Task<T> InitClient<T>(Func<T, Task> action, bool execute = true) where T :
133
133
return client ;
134
134
}
135
135
136
- // static Version GetEventStoreVersion() {
137
- // const string versionPrefix = "EventStoreDB version";
138
- //
139
- // using var cancellator = new CancellationTokenSource(FromSeconds(30));
140
- // using var eventstore = new Builder()
141
- // .UseContainer()
142
- // .UseImage(GlobalEnvironment.DockerImage)
143
- // .Command("--version")
144
- // .Build()
145
- // .Start();
146
- //
147
- // using var log = eventstore.Logs(true, cancellator.Token);
148
- // foreach (var line in log.ReadToEnd()) {
149
- // if (line.StartsWith(versionPrefix) &&
150
- // Version.TryParse(
151
- // new string(ReadVersion(line[(versionPrefix.Length + 1)..]).ToArray()),
152
- // out var version
153
- // )) {
154
- // return version;
155
- // }
156
- // }
157
- //
158
- // throw new InvalidOperationException("Could not determine server version.");
159
- //
160
- // IEnumerable<char> ReadVersion(string s) {
161
- // foreach (var c in s.TakeWhile(c => c == '.' || char.IsDigit(c))) {
162
- // yield return c;
163
- // }
164
- // }
165
- // }
136
+ static Version GetEventStoreVersion ( ) {
137
+ const string versionPrefix = "EventStoreDB version" ;
138
+
139
+ using var cancellator = new CancellationTokenSource ( FromSeconds ( 30 ) ) ;
140
+ using var eventstore = new Builder ( )
141
+ . UseContainer ( )
142
+ . UseImage ( GlobalEnvironment . DockerImage )
143
+ . Command ( "--version" )
144
+ . Build ( )
145
+ . Start ( ) ;
146
+
147
+ using var log = eventstore . Logs ( true , cancellator . Token ) ;
148
+ foreach ( var line in log . ReadToEnd ( ) ) {
149
+ Logger . Warning ( "line---> {line}" , line ) ;
150
+
151
+ if ( line . StartsWith ( versionPrefix ) &&
152
+ Version . TryParse (
153
+ new string ( ReadVersion ( line [ ( versionPrefix . Length + 1 ) ..] ) . ToArray ( ) ) ,
154
+ out var version
155
+ ) ) {
156
+ return version ;
157
+ }
158
+ }
159
+
160
+ throw new InvalidOperationException ( "Could not determine server version." ) ;
161
+
162
+ IEnumerable < char > ReadVersion ( string s ) {
163
+ foreach ( var c in s . TakeWhile ( c => c == '.' || char . IsDigit ( c ) ) ) {
164
+ yield return c ;
165
+ }
166
+ }
167
+ }
166
168
}
167
169
168
170
public async Task DisposeAsync ( ) {
0 commit comments