public static void main()

in harry-core/src/harry/runner/TrivialShrinker.java [42:164]


    public static void main(String[] args) throws Throwable
    {
        try
        {
            File configFile = HarryRunner.loadConfig(args);
            Configuration configuration = Configuration.fromFile(configFile);
            System.out.println(Configuration.toYamlString(configuration));

            Set<Long> pdsToSkip = new HashSet<>(Arrays.asList(
            // put pds you want to skip here, or Harry will find them for you
            ));

            Set<Long> ltsToSkip = new HashSet<>(Arrays.asList(
            // put lts you want to skip here, or Harry will find them for you
            ));

            // Which LTS failure has occurred on
            final long maxLts = 7000L;

            // Check if we've found exactly the exception that is causing the failure
            Predicate<Exception> check = (e) -> true;

            Run run = configuration.createRun();
            Configuration.SequentialRunnerConfig config = (Configuration.SequentialRunnerConfig) configuration.runner;
            List<Visitor> visitors = new ArrayList<>();
            for (Configuration.VisitorConfiguration factory : config.visitorFactories)
            {
                Visitor visitor = factory.make(run);
                if (visitor instanceof LtsVisitor)
                {
                    AtomicLong counter = new AtomicLong();
                    visitors.add(new SkippingVisitor((LtsVisitor) visitor,
                                                     counter::getAndIncrement,
                                                     (lts) -> run.pdSelector.pd(lts, run.schemaSpec),
                                                     ltsToSkip,
                                                     pdsToSkip)) ;
                }
                else
                {
                    visitors.add(visitor);
                }
            }

            Set<Long> partitions = new HashSet<>();
            for (long i = 0; i < maxLts; i++)
                partitions.add(run.pdSelector.pd(i, run.schemaSpec));

            // Step one: figure out which partitions we can skip while still keeping it reproducible
            for (Long pdToCheck : partitions)
            {
                if (pdsToSkip.contains(pdToCheck))
                    continue;
                pdsToSkip.add(pdToCheck);
                Runner.init(configuration, run);

                try
                {
                    runOnce(visitors, maxLts);
                    System.out.println("Can not skip " + pdToCheck + "\nCan only skip these: " + toString(pdsToSkip));
                    pdsToSkip.remove(pdToCheck);
                }
                catch (RuntimeException t)
                {
                    if (check.test(t))
                    {
                        System.out.printf("Safe to skip: %d because without it we're still hitting an exception %s.\n%s\n",
                                          pdToCheck,
                                          t.getMessage(),
                                          toString(pdsToSkip));
                    }
                    else
                    {
                        System.out.println("Can not skip " + pdToCheck + "\n, since we seem to repro a different issue. Can only skip these: " + toString(pdsToSkip));
                        pdsToSkip.remove(pdToCheck);
                    }
                }
                run.sut.schemaChange("DROP KEYSPACE " + run.schemaSpec.keyspace);
            }

            // Step two: figure out which lts can be skipped within the remaining partitions
            for (long lts = 0; lts < maxLts; lts++)
            {
                long ltsToCheck = lts;
                if (ltsToSkip.contains(ltsToCheck) || pdsToSkip.contains(run.pdSelector.pd(lts, run.schemaSpec)))
                    continue;
                ltsToSkip.add(ltsToCheck);
                Runner.init(configuration, run);

                try
                {
                    runOnce(visitors, maxLts);
                    System.out.println("Can not skip " + ltsToCheck + "\nCan only skip these: " + toString(ltsToSkip));
                    ltsToSkip.remove(ltsToCheck);
                }
                catch (RuntimeException t)
                {
                    if (check.test(t))
                    {
                        System.out.printf("Safe to skip: %d because without it we're still hitting an exception %s.\n%s\n",
                                          ltsToCheck,
                                          t.getMessage(),
                                          toString(ltsToSkip));
                    }
                    else
                    {
                        System.out.println("Can not skip " + lts + "\n, since we seem to repro a different issue. Can only skip these: " + toString(ltsToSkip));
                        ltsToSkip.remove(ltsToCheck);
                    }

                }
                run.sut.schemaChange("DROP KEYSPACE " + run.schemaSpec.keyspace);
            }
        }
        catch (Throwable t)
        {
            System.out.println(t.getMessage());
            t.printStackTrace();
        }
        finally
        {
            System.exit(1);
        }
    }