Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Closes #6637: Support for v34 fennec database migrations migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Grisha Kruglov authored and pocmo committed Apr 14, 2020
1 parent a3c9373 commit 5288e1e
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 13 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object Versions {
const val disklrucache = "2.0.2"
const val leakcanary = "1.6.3"

const val mozilla_appservices = "0.55.0"
const val mozilla_appservices = "0.55.2"

const val mozilla_glean = "25.0.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,106 @@ class PlacesBookmarksStorageTest {
}

@Test
fun `bookmarks import v38 populated`() {
// Fennec v38 schema populated with data.
fun `bookmarks import v34 populated`() = runBlocking {
val path = getTestPath("databases/history-v34.db").absolutePath

// Need to import history first before we import bookmarks.
PlacesHistoryStorage(testContext).importFromFennec(path)
bookmarks.importFromFennec(path)

with(bookmarks.getTree(BookmarkRoot.Root.id)!!) {
assertEquals(4, this.children!!.size)
val children = this.children!!.map { it.guid }
assertTrue(BookmarkRoot.Mobile.id in children)
assertTrue(BookmarkRoot.Unfiled.id in children)
assertTrue(BookmarkRoot.Toolbar.id in children)
assertTrue(BookmarkRoot.Menu.id in children)
}

with(bookmarks.getTree(BookmarkRoot.Mobile.id)!!) {
assertEquals(3, this.children!!.size)
with(this.children!![0]) {
assertEquals("Firefox: About your browser", this.title)
assertEquals("about:firefox", this.url)
assertEquals("t4ov0nhBpPAY", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![1]) {
assertEquals("Firefox: Customize with add-ons", this.title)
assertEquals("https://addons.mozilla.org/android?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid", this.url)
assertEquals("dhoCQAToruIT", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![2]) {
assertEquals("Firefox: Support", this.title)
assertEquals("https://support.mozilla.org/products/mobile?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid", this.url)
assertEquals("gIqii_3QBZWG", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
}
}

@Test
fun `bookmarks import v38 populated`() = runBlocking {
val path = getTestPath("databases/populated-v38.db").absolutePath
try {
bookmarks.importFromFennec(path)
fail("Expected v38 database to be unsupported")
} catch (e: PlacesException) {
// This is a little brittle, but the places library doesn't have a proper error type for this.
assertEquals("Database version 38 is not supported", e.message)

// Need to import history first before we import bookmarks.
PlacesHistoryStorage(testContext).importFromFennec(path)
bookmarks.importFromFennec(path)

with(bookmarks.getTree(BookmarkRoot.Root.id)!!) {
assertEquals(4, this.children!!.size)
val children = this.children!!.map { it.guid }
assertTrue(BookmarkRoot.Mobile.id in children)
assertTrue(BookmarkRoot.Unfiled.id in children)
assertTrue(BookmarkRoot.Toolbar.id in children)
assertTrue(BookmarkRoot.Menu.id in children)
}

with(bookmarks.getTree(BookmarkRoot.Mobile.id)!!) {
assertEquals(7, this.children!!.size)
with(this.children!![0]) {
assertEquals("Firefox: About your browser", this.title)
assertEquals("about:firefox", this.url)
assertEquals("9MVmaUmIEKST", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![1]) {
assertEquals("Firefox: Customize with add-ons", this.title)
assertEquals("https://addons.mozilla.org/android?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid", this.url)
assertEquals("-wR8auFiXifM", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![2]) {
assertEquals("Firefox: Support", this.title)
assertEquals("https://support.mozilla.org/products/mobile?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid", this.url)
assertEquals("UUJ5Ru2TouvB", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![3]) {
assertEquals("Problem loading page", this.title)
assertEquals("file:///", this.url)
assertEquals("YWIdMNLBXzUa", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![4]) {
assertEquals("Kotaku - The Gamer's Guide", this.title)
assertEquals("http://kotaku.com/", this.url)
assertEquals("_nrbwE-uDI4w", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![5]) {
assertEquals("News, sport and opinion from the Guardian's US edition | The Guardian", this.title)
assertEquals("https://www.theguardian.com/us", this.url)
assertEquals("9pdaS9QzEwYy", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![6]) {
assertEquals("Rollins Pass - Wikipedia", this.title)
assertEquals("https://en.m.wikipedia.org/wiki/Rollins_Pass#/random", this.url)
assertEquals("mEFfANXkYH6T", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,15 +709,41 @@ class PlacesHistoryStorageTest {
}

@Test
fun `history import v38 populated`() {
fun `history import v23 populated`() {
// Fennec v38 schema populated with data.
val path = getTestPath("databases/populated-v38.db").absolutePath
val path = getTestPath("databases/bookmarks-v23.db").absolutePath
try {
history.importFromFennec(path)
fail("Expected v38 database to be unsupported")
fail("Expected v23 database to be unsupported")
} catch (e: PlacesException) {
// This is a little brittle, but the places library doesn't have a proper error type for this.
assertEquals("Database version 38 is not supported", e.message)
assertEquals("Database version 23 is not supported", e.message)
}
}

@Test
fun `history import v38 populated`() = runBlocking {
val path = getTestPath("databases/populated-v38.db").absolutePath
var visits = history.getDetailedVisits(0, Long.MAX_VALUE)
assertEquals(0, visits.size)
history.importFromFennec(path)

visits = history.getDetailedVisits(0, Long.MAX_VALUE)
assertEquals(152, visits.size)

assertEquals(listOf(false, false, true, true, false), history.reader.getVisited(listOf(
"files:///",
"https://news.ycombinator.com/",
"https://www.theguardian.com/film/2017/jul/24/stranger-things-thor-ragnarok-comic-con-2017",
"http://www.bbc.com/news/world-us-canada-40662772",
"https://mobile.reuters.com/"
)))

with(visits[0]) {
assertEquals("Apple", this.title)
assertEquals("http://www.apple.com/", this.url)
assertEquals(1472685165382, this.visitTime)
assertEquals(VisitType.REDIRECT_PERMANENT, this.visitType)
}
}

Expand Down Expand Up @@ -778,6 +804,62 @@ class PlacesHistoryStorageTest {
assertEquals(VisitType.LINK, this.visitType)
}
}

@Test
fun `history import v34 populated`() = runBlocking {
val path = getTestPath("databases/history-v34.db").absolutePath
var visits = history.getDetailedVisits(0, Long.MAX_VALUE)
assertEquals(0, visits.size)
history.importFromFennec(path)

visits = history.getDetailedVisits(0, Long.MAX_VALUE)
assertEquals(6, visits.size)

assertEquals(listOf(true, true, true, true, true), history.reader.getVisited(listOf(
"https://www.newegg.com/",
"https://news.ycombinator.com/",
"https://terrytao.wordpress.com/2020/04/12/john-conway/",
"https://news.ycombinator.com/item?id=22862053",
"https://malleable.systems/"
)))

with(visits[0]) {
assertEquals("Computer Parts, PC Components, Laptop Computers, LED LCD TV, Digital Cameras and more - Newegg.com", this.title)
assertEquals("https://www.newegg.com/", this.url)
assertEquals(1586838104188, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[1]) {
assertEquals("Hacker News", this.title)
assertEquals("https://news.ycombinator.com/", this.url)
assertEquals(1586838109506, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[2]) {
assertEquals("https://terrytao.wordpress.com/2020/04/12/john-conway/", this.title)
assertEquals("https://terrytao.wordpress.com/2020/04/12/john-conway/", this.url)
assertEquals(1586838113212, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[3]) {
assertEquals("John Conway | Hacker News", this.title)
assertEquals("https://news.ycombinator.com/item?id=22862053", this.url)
assertEquals(1586838123314, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[4]) {
assertEquals("John Conway | Hacker News", this.title)
assertEquals("https://news.ycombinator.com/item?id=22862053", this.url)
assertEquals(1586838126671, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[5]) {
assertEquals("https://malleable.systems/", this.title)
assertEquals("https://malleable.systems/", this.url)
assertEquals(1586838164613, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
}
}

fun getTestPath(path: String): File {
Expand Down
Binary file not shown.
Binary file not shown.

28 comments on commit 5288e1e

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:4b2de5ca-0002-005f-7455-12c5e1000000
Time:2020-04-14T12:05:34.8078728Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:7830753d-8002-0041-7755-122939000000
Time:2020-04-14T12:05:42.8900110Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:ce2e4c89-2002-0005-3155-12a306000000
Time:2020-04-14T12:05:49.1787093Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:3d815a81-0002-002d-6955-12c2ae000000
Time:2020-04-14T12:05:49.8748844Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:9d9e559d-6002-0049-2b55-123336000000
Time:2020-04-14T12:05:52.3211054Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:45b9a7ce-c002-0022-0f55-12b4c2000000
Time:2020-04-14T12:05:54.7934370Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:058cdb3e-5002-0030-7558-12cf12000000
Time:2020-04-14T12:32:27.3135074Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:211b648b-5002-006d-3e58-12c596000000
Time:2020-04-14T12:32:27.4631756Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:80d2ad95-5002-0099-4d58-120e60000000
Time:2020-04-14T12:32:27.8247221Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:771170de-9002-0072-0258-127692000000
Time:2020-04-14T12:32:28.7379090Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:d2e92660-f002-0029-0558-124fa9000000
Time:2020-04-14T12:32:28.7300131Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:b2fa522f-7002-008e-4058-12a76b000000
Time:2020-04-14T12:32:28.7847510Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:f26ecc25-2002-0093-2d58-12aad7000000
Time:2020-04-14T12:32:28.7459637Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:ec2ab34e-b002-0075-4858-121af1000000
Time:2020-04-14T12:32:30.4095636Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:ec2ab4a8-b002-0075-0958-121af1000000
Time:2020-04-14T12:32:34.1682065Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:c8ab5ca1-1002-0043-1a58-129781000000
Time:2020-04-14T12:32:34.2555317Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:771178da-9002-0072-2758-127692000000
Time:2020-04-14T12:32:41.8272751Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:59154ef2-a002-0034-4f58-124215000000
Time:2020-04-14T12:32:44.1941181Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:ec2abcb4-b002-0075-0658-121af1000000
Time:2020-04-14T12:32:53.8130166Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:f26ed65d-2002-0093-1958-12aad7000000
Time:2020-04-14T12:33:04.4766581Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:b65df870-f002-005b-5558-1248e6000000
Time:2020-04-14T12:33:11.2828056Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:b65e0744-f002-005b-5c58-1248e6000000
Time:2020-04-14T12:33:41.4350374Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:ec2ad22e-b002-0075-4a58-121af1000000
Time:2020-04-14T12:33:47.2435741Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:7833852c-8002-0041-2658-122939000000
Time:2020-04-14T12:33:59.9344617Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:ec2ad6ff-b002-0075-4958-121af1000000
Time:2020-04-14T12:34:00.5219107Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:b65e1117-f002-005b-5258-1248e6000000
Time:2020-04-14T12:34:01.2299742Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:c8aba20a-1002-0043-0458-129781000000
Time:2020-04-14T12:34:05.4894706Z

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

The specified entity already exists.
RequestId:d2e95703-f002-0029-1058-124fa9000000
Time:2020-04-14T12:34:06.7403134Z

Please sign in to comment.