Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #117 from lpabon/fix_116
Browse files Browse the repository at this point in the history
NodeDelete needs to be asynchronous
  • Loading branch information
Luis Pabón committed Aug 7, 2015
2 parents ce40304 + fd68452 commit f7f28ec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
11 changes: 6 additions & 5 deletions apps/glusterfs/app_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ func (a *App) NodeDelete(w http.ResponseWriter, r *http.Request) {
return
}

// Show that the key has been deleted
logger.Info("Deleted node [%s]", id)

// Write msg
w.WriteHeader(http.StatusOK)
a.asyncManager.AsyncHttpRedirectFunc(w, r, func() (string, error) {
time.Sleep(1 * time.Second)
// Show that the key has been deleted
logger.Info("Deleted node [%s]", id)
return "", nil
})
}
18 changes: 17 additions & 1 deletion apps/glusterfs/app_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,23 @@ func TestNodeAddDelete(t *testing.T) {
tests.Assert(t, err == nil)
r, err = http.DefaultClient.Do(req)
tests.Assert(t, err == nil)
tests.Assert(t, r.StatusCode == http.StatusOK)
tests.Assert(t, r.StatusCode == http.StatusAccepted)
location, err = r.Location()
tests.Assert(t, err == nil)

// Wait for deletion
for {
r, err := http.Get(location.String())
tests.Assert(t, err == nil)
if r.Header.Get("X-Pending") == "true" {
tests.Assert(t, r.StatusCode == http.StatusOK)
time.Sleep(time.Millisecond * 10)
continue
} else {
tests.Assert(t, r.StatusCode == http.StatusNoContent)
break
}
}

// Check db to make sure key is removed
err = app.db.View(func(tx *bolt.Tx) error {
Expand Down

0 comments on commit f7f28ec

Please sign in to comment.