kite-sdk / kite

Kite SDK
http://kitesdk.org/docs/current/
Apache License 2.0
394 stars 263 forks source link

KITE-1072: Fix SchemaTool flaky test. #412

Closed rdblue closed 9 years ago

rdblue commented 9 years ago

This makes all of the tests use a randomly-generated table name. The directory migration test began failing because the table didn't already exist, so I created the table using createOrMigrateFile first and then ran createOrMigrateDirectory. This appears to have fixed the problem.

rdblue commented 9 years ago

@prazanna or @jackowaya could you review this?

prazanna commented 9 years ago

Looks good to me!

jackowaya commented 9 years ago

This doesn't make sense to me. I think that createOrMigrateDirectory will pick up the table name from the schema file, so the change to the table name won't affect what the test is supposed to check, but then we're building a scanner on the random table name, so it seems to me like we're not really testing createOrMigrateDirectory there.

I can't get the failure to happen, so it's hard for me to see the issue.

rdblue commented 9 years ago

You can't get the failure to happen? I'll double-check then.

prazanna commented 9 years ago

Yes, I overlooked. testMigrateDirectory() should fail if we create a random table name as the table names should be picked up from the schema. testMigrateFile() and testMigrateSchema() should be fine with random table names. If the problem is sometimes the simple table does not get removed properly, we could may be use "simple" as the table name only for testMigrateDirectory() test.

rdblue commented 9 years ago

The problem is this:

org.kitesdk.data.SchemaNotFoundException: Could not find managed schemas for 9fa7e2e0, SimpleHBaseRecord
    at org.kitesdk.data.hbase.manager.DefaultSchemaManager.getManagedSchema(DefaultSchemaManager.java:496)
    at org.kitesdk.data.hbase.manager.DefaultSchemaManager.getKeySchema(DefaultSchemaManager.java:103)
    at org.kitesdk.data.hbase.avro.VersionedAvroEntityMapper.<init>(VersionedAvroEntityMapper.java:158)
    at org.kitesdk.data.hbase.avro.VersionedAvroEntityMapper.<init>(VersionedAvroEntityMapper.java:57)
    at org.kitesdk.data.hbase.avro.VersionedAvroEntityMapper$Builder.build(VersionedAvroEntityMapper.java:118)
    at org.kitesdk.data.hbase.avro.SpecificAvroDao.<init>(SpecificAvroDao.java:124)
    at org.kitesdk.data.hbase.tool.SchemaToolTest.testMigrateDirectory(SchemaToolTest.java:90)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

What @prazanna is saying makes sense - if the table is hard-coded in the schema then we should be testing with "simple" for just that case. It is odd that testOrMigrateDirectory takes a table name and fails when that table doesn't exist, but I can get the test working by replacing it with "simple". I think this is just a bug in testOrMigrateDirectory that it takes a table name at all.

rdblue commented 9 years ago

Ignore my last comment, I just looked at the test, which validates that the table name was created. If the table name is "simple" because it is defined in the schema then everything makes sense. createOrMigrateDirectory doesn't take a table name at all, that was my mistake.

jackowaya commented 9 years ago

This now looks right to me if it is fixing your flaky tests.