This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
forked from StreakYC/mache
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds test case for StreakYC#12 and properly fix it.
Fixes misuse of query predicates on previous commit of BuiltinDatastoreToBigqueryIngesterTask, that was causing it to fail backwards. Also adds a new test case to the test suite so this can be verified as fixed.
- Loading branch information
Showing
3 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ava/com/streak/datastore/analysis/builtin/BuiltinDatastoreToBigqueryIngesterTaskTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.streak.datastore.analysis.builtin; | ||
|
||
import static com.google.appengine.api.datastore.KeyFactory.*; | ||
import static org.junit.Assert.*; | ||
|
||
import java.util.*; | ||
import java.util.logging.*; | ||
import com.google.appengine.api.datastore.*; | ||
|
||
import org.junit.*; | ||
import com.google.appengine.tools.development.testing.*; | ||
|
||
public class BuiltinDatastoreToBigqueryIngesterTaskTest { | ||
|
||
private static final Logger LOG = Logger.getLogger( // | ||
BuiltinDatastoreToBigqueryIngesterTaskTest.class.getName()); | ||
|
||
private DatastoreService ds; | ||
|
||
private LocalServiceTestHelper helper = | ||
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()); | ||
|
||
private static Integer operation = 1; | ||
|
||
@Before | ||
public void setUpDatastore() { | ||
helper.setUp(); | ||
ds = DatastoreServiceFactory.getDatastoreService(); | ||
} | ||
|
||
@After | ||
public void tearDownDatastore() { | ||
helper.tearDown(); | ||
} | ||
|
||
@Test | ||
public void testCheckAndGetCompletedBackup() throws Exception { | ||
long ts = System.currentTimeMillis(); | ||
String targetName = "current_backup" + ts; | ||
|
||
fixtureForBackup("a_previous_backup", new Date()); | ||
fixtureForBackup(targetName, null); | ||
fixtureForBackup("z_latest_backup" + ts, new Date()); | ||
|
||
BuiltinDatastoreToBigqueryIngesterTask task = new BuiltinDatastoreToBigqueryIngesterTask(); | ||
assertNull(task.checkAndGetCompletedBackup(targetName)); | ||
} | ||
|
||
private synchronized Entity fixtureForBackup(String name, Date completeTime) { | ||
Key ancestor = createKey("_AE_DatastoreAdmin_Operation", ++operation); | ||
Entity e = new Entity(createKey(ancestor, "_AE_Backup_Information", ++operation)); | ||
e.setProperty("name", name); | ||
e.setProperty("complete_time", completeTime); | ||
|
||
ds.put(e); | ||
LOG.info("Added fixture for " + e.toString()); | ||
return e; | ||
} | ||
} |