Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add db test in read-only mode #46

Merged
merged 1 commit into from
Sep 12, 2017
Merged

Conversation

lorneli
Copy link
Contributor

@lorneli lorneli commented Sep 12, 2017

No description provided.

@lorneli lorneli changed the title Add db test in read-only mode add db test in read-only mode Sep 12, 2017
@codecov-io
Copy link

codecov-io commented Sep 12, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@4d3ab93). Click here to learn what that means.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #46   +/-   ##
=========================================
  Coverage          ?   85.56%           
=========================================
  Files             ?        9           
  Lines             ?     1857           
  Branches          ?        0           
=========================================
  Hits              ?     1589           
  Misses            ?      159           
  Partials          ?      109
Impacted Files Coverage Δ
db.go 82.83% <100%> (ø)
bolt_unix.go 70.45% <33.33%> (ø)
tx.go 76.21% <83.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d3ab93...d294ec8. Read the comment docs.

@lorneli
Copy link
Contributor Author

lorneli commented Sep 12, 2017

This pr tests read-only mode db, which should increase test coverage, like this line https://codecov.io/gh/coreos/bbolt/src/master/db.go#L179 Confused about the codecov report:sweat:

o := &bolt.Options{ReadOnly: true}
readOnlyDB, err := bolt.Open(f, 0666, o)
if err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

t.Fatal(err)

db_test.go Outdated
}
return nil
}); err != nil {
log.Fatal(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

t.Fatal(err)

db_test.go Outdated
}

if err := readOnlyDB.Close(); err != nil {
log.Fatal(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

t.Fatal(err)

db_test.go Outdated
@@ -1125,6 +1125,61 @@ func TestDB_BatchTime(t *testing.T) {
}
}

// Ensure that a database in read only mode can read from read-only transaction,
// but can't launch read-write transaction.
func TestDB_ReadOnlyMode(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

TestDB_Open_ReadOnly to match TestDB_Open_InitialMmapSize

@@ -1449,15 +1504,7 @@ type DB struct {

// MustOpenDB returns a new, open DB at a temporary location.
func MustOpenDB() *DB {
Copy link
Contributor

Choose a reason for hiding this comment

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

squash commit

db_test.go Outdated
}); err != nil {
t.Fatal(err)
}
err := db.DB.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

if err := db.DB.Close(); err != nil {

to match other if's

db_test.go Outdated
@@ -1125,6 +1125,61 @@ func TestDB_BatchTime(t *testing.T) {
}
}

// Ensure that a database in read only mode can read from read-only transaction,
Copy link
Contributor

Choose a reason for hiding this comment

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

use godoc style:

TestDB_Open_ReadOnly checks a database in read only mode can read but not write.

@lorneli
Copy link
Contributor Author

lorneli commented Sep 12, 2017

I have updated commit and moved TestDB_Open_ReadOnly below TestDB_Open_InitialMmapSize.

@lorneli lorneli closed this Sep 12, 2017
@xiang90
Copy link
Contributor

xiang90 commented Sep 12, 2017

@lorneli why this is closed?

Copy link
Contributor

@heyitsanthony heyitsanthony left a comment

Choose a reason for hiding this comment

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

lgtm thanks

@heyitsanthony
Copy link
Contributor

@lorneli is this OK to merge?

@xiang90 xiang90 reopened this Sep 12, 2017
@xiang90
Copy link
Contributor

xiang90 commented Sep 12, 2017

@heyitsanthony I believe he accidentally closed the PR when commenting. we can just merge this in.

@heyitsanthony heyitsanthony merged commit 63f0e07 into etcd-io:master Sep 12, 2017
@lorneli
Copy link
Contributor Author

lorneli commented Sep 13, 2017

@heyitsanthony @xiang90 I accidentally closed this PR when commenting on mobile phone. Its screen is too small.... Thank you for your review.

@lorneli lorneli deleted the bbolt_db_test branch September 13, 2017 09:12
@gyuho gyuho changed the title add db test in read-only mode Add db test in read-only mode Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants