dcapwell commented on code in PR #3441:
URL: https://github.com/apache/cassandra/pull/3441#discussion_r1691876289


##########
test/simulator/test/org/apache/cassandra/simulator/test/HarrySimulatorTest.java:
##########
@@ -504,43 +527,38 @@ public void shutdown()
     /**
      * Simulation entrypoint; syntax sugar for creating a simulation.
      */
-    static void simulate(Consumer<ClusterSimulation.Builder<HarrySimulation>> 
configure,
-                         Consumer<IInstanceConfig> instanceConfigUpdater,
-                         Configuration.ConfigurationBuilder harryConfig,
-                         String[] properties,
-                         Function<HarrySimulation, ActionSchedule.Work[]>... 
phases) throws IOException
+    void simulate(Consumer<ClusterSimulation.Builder<HarrySimulation>> 
configure,
+                  Consumer<IInstanceConfig> instanceConfigUpdater,
+                  Configuration.ConfigurationBuilder harryConfig,
+                  String[] properties,
+                  Function<HarrySimulation, ActionSchedule.Work[]>... phases) 
throws IOException
     {
         try (WithProperties p = new WithProperties().with(properties))
         {
             HarrySimulationBuilder factory = new 
HarrySimulationBuilder(harryConfig, instanceConfigUpdater);
 
             SimulationRunner.beforeAll();
-            long seed = System.currentTimeMillis();
-            // Development seed:
-            //long seed = 1687184561194L;
-            System.out.println("Simulation seed: " + seed + "L");
+            long seed = 
SimulationRunner.parseHex(Optional.ofNullable(this.seed)).orElseGet(() -> new 
Random().nextLong());
+            logger.info("Seed 0x{}", Long.toHexString(seed));
             configure.accept(factory);
             try (ClusterSimulation<HarrySimulation> clusterSimulation = 
factory.create(seed))
             {
-                try
-                {
-                    HarrySimulation simulation = 
clusterSimulation.simulation();
-
-                    // For better determinism during startup, we allow 
instances to fully start (including daemon work)
-                    for (int i = 0; i < phases.length; i++)
-                    {
-                        HarrySimulation current = simulation;
-                        if (i == 0)
-                            current = current.withScheduler(new 
RunnableActionScheduler.Immediate()).withSchedulers((s) -> 
Collections.emptyMap());
-                        current.withSchedule(phases[i]).run();
-                    }
-                }
-                catch (Throwable t)
+                HarrySimulation simulation = clusterSimulation.simulation();
+
+                // For better determinism during startup, we allow instances 
to fully start (including daemon work)
+                for (int i = 0; i < phases.length; i++)
                 {
-                    throw new AssertionError(String.format("Failed on seed 
%s", Long.toHexString(seed)),
-                                             t);
+                    HarrySimulation current = simulation;
+                    if (i == 0)
+                        current = current.withScheduler(new 
RunnableActionScheduler.Immediate()).withSchedulers((s) -> 
Collections.emptyMap());
+                    current.withSchedule(phases[i]).run();
                 }
             }
+            catch (Throwable t)
+            {
+                if (t instanceof SimulationException) throw t;
+                throw new SimulationException(seed, "Failure creating the 
simulation", t);

Review Comment:
   the error is consistent for other tests, so migrating to that handling... 
right now the seed is lost most of the time, so this makes sure it is captured 
100% of the time



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to