@@ -44,6 +44,7 @@ public static class CoreTestConfiguration
44
44
private static ConnectionString __connectionString = GetConnectionString ( ) ;
45
45
private static DatabaseNamespace __databaseNamespace = GetDatabaseNamespace ( ) ;
46
46
private static MessageEncoderSettings __messageEncoderSettings = new MessageEncoderSettings ( ) ;
47
+ private static TraceSource __traceSource ;
47
48
48
49
// static properties
49
50
public static ICluster Cluster
@@ -75,6 +76,11 @@ public static SemanticVersion ServerVersion
75
76
}
76
77
}
77
78
79
+ public static TraceSource TraceSource
80
+ {
81
+ get { return __traceSource ; }
82
+ }
83
+
78
84
// static methods
79
85
public static ClusterBuilder ConfigureCluster ( )
80
86
{
@@ -133,12 +139,12 @@ public static ClusterBuilder ConfigureLogging(ClusterBuilder builder)
133
139
return builder ;
134
140
}
135
141
136
- var traceSource = new TraceSource ( "mongodb-tests" , defaultLevel ) ;
137
- traceSource . Listeners . Clear ( ) ; // remove the default listener
142
+ __traceSource = new TraceSource ( "mongodb-tests" , defaultLevel ) ;
143
+ __traceSource . Listeners . Clear ( ) ; // remove the default listener
138
144
var listener = new ConsoleTraceListener ( ) ;
139
145
listener . TraceOutputOptions = TraceOptions . DateTime ;
140
- traceSource . Listeners . Add ( listener ) ;
141
- return builder . TraceWith ( traceSource ) ;
146
+ __traceSource . Listeners . Add ( listener ) ;
147
+ return builder . TraceWith ( __traceSource ) ;
142
148
}
143
149
144
150
public static ICluster CreateCluster ( )
@@ -150,8 +156,18 @@ public static ICluster CreateCluster()
150
156
{
151
157
var anyWritableServer = e . NewClusterDescription . Servers . Any (
152
158
description => description . Type . IsWritable ( ) ) ;
159
+ if ( __traceSource != null )
160
+ {
161
+ __traceSource . TraceEvent ( TraceEventType . Information , 0 , $ "CreateCluster: DescriptionChanged event handler called.") ;
162
+ __traceSource . TraceEvent ( TraceEventType . Information , 0 , $ "CreateCluster: anyWritableServer = { anyWritableServer } .") ;
163
+ __traceSource . TraceEvent ( TraceEventType . Information , 0 , $ "CreateCluster: new description: { e . NewClusterDescription . ToString ( ) } .") ;
164
+ }
153
165
Interlocked . Exchange ( ref hasWritableServer , anyWritableServer ? 1 : 0 ) ;
154
166
} ;
167
+ if ( __traceSource != null )
168
+ {
169
+ __traceSource . TraceEvent ( TraceEventType . Information , 0 , "CreateCluster: initializing cluster." ) ;
170
+ }
155
171
cluster . Initialize ( ) ;
156
172
157
173
// wait until the cluster has connected to a writable server
@@ -164,6 +180,11 @@ public static ICluster CreateCluster()
164
180
throw new Exception ( message ) ;
165
181
}
166
182
183
+ if ( __traceSource != null )
184
+ {
185
+ __traceSource . TraceEvent ( TraceEventType . Information , 0 , "CreateCluster: writable server found." ) ;
186
+ }
187
+
167
188
return cluster ;
168
189
}
169
190
0 commit comments