ModelInference / synoptic

Inferring models of systems from observations of their behavior
Other
81 stars 25 forks source link

JsonExporter changes #409

Open wborkofsky opened 7 years ago

ohmann commented 7 years ago

You can manually run the whole Perfume algorithm to get a partition graph for your tests. Try this skeleton test class I made, and you can add your actual tests to it. Please don't actually use file i/o like my fake renameMeTest does. Change JsonExporter so that you can test it without actually outputting a file (just refactor it so that you aren't forced to generate the json and output a file, since this is currently all within the only entry point, exportJsonObject()).

package synoptic.tests.units;

import java.util.Arrays;

import org.junit.Before;
import org.junit.Test;

import synoptic.main.AbstractMain;
import synoptic.main.PerfumeMain;
import synoptic.main.options.PerfumeOptions;
import synoptic.model.PartitionGraph;
import synoptic.model.export.DotExportFormatter;
import synoptic.model.export.JsonExporter;

/**
 * TODO
 */
public class JsonExporterTests {
    private PerfumeMain main;
    private PartitionGraph pGraph;

    @Before
    public void setUp() throws Exception {
        // Set up Perfume options
        PerfumeOptions perfOpts = new PerfumeOptions();
        perfOpts.regExps = Arrays.asList(
                new String[] { "(?<ip>.+), (?<TYPE>.+), (?<DTIME>.+)" });
        perfOpts.partitionRegExp = "\\k<ip>";
        perfOpts.logFilenames.add(
                "../traces/abstract/perfume-survey/browser-caching-traces.txt");

        // Create a Perfume instance
        AbstractMain.instance = null;
        main = new PerfumeMain(perfOpts.toAbstractOptions(),
                new DotExportFormatter());

        // Run Perfume
        pGraph = main.createInitialPartitionGraph();
        main.runSynoptic(pGraph);
    }

    /**
     * TODO
     */
    @Test
    public void renameMeTest() throws Exception {
        JsonExporter.exportJsonObject("/tmp/JsonExporterTest", pGraph);
    }
}
ohmann commented 7 years ago

@wborkofsky I apologize that I forgot about this pull request. Did your changes after my March 29 comments address all of my comments, i.e., am I up to bat on this? I saw that at least some of the comments were addressed, but I saw that you didn't remove the abc file, and I didn't look closely enough to see if you did anything with my request to do a set comparison of some of the fields for actual vs. expected, e.g., expected edge displayables are {"cache-image", "retrieve-image"}, then ensure the actual JSON contains exactly those same edge displayables. (As I mentioned in the comment, it would be hard and annoying to ensure the expected/actual JSON exactly matches up because IDs will change, but this is sort of getting halfway there.)

If everything is addressed or you have responses to any comments you didn't address, please let me know, and I'll take another look!

ohmann commented 6 years ago

@wborkofsky Just a quick ping on my question from above: "Did your changes after my March 29 comments address all of my comments, i.e., am I up to bat on this?"

wborkofsky commented 6 years ago

@ohmann It appears that I did add in all the test code for set equality. For the file "abc", in my commit, it shows as all lines removed so I believe it should have been removed as well and it does not appear in the synoptic version on my computer.