-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testing and error handling for block assignment and distribution
- Loading branch information
Showing
6 changed files
with
100 additions
and
36 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package namenode | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestInvalidInput(t *testing.T) { | ||
|
||
Init() | ||
|
||
dn1 := datanode{"DN1", true, 0} | ||
datanodemap["DN1"] = &dn1 | ||
|
||
// Test a bad block | ||
var b1 Block | ||
|
||
_, err := AssignBlock(b1) | ||
|
||
if err == nil { | ||
t.Errorf("Distributed invalid Block") | ||
} | ||
} | ||
|
||
func TestValidInput(t *testing.T) { | ||
|
||
Init() | ||
|
||
dn1 := datanode{"DN1", true, 0} | ||
datanodemap["DN1"] = &dn1 | ||
|
||
// Test a bad block | ||
var b1 Block | ||
|
||
inh := BlockHeader{"DN1", "/out.txt", 1, 0, 1} | ||
b1.Header = inh | ||
b1.Data = make([]byte, 1, 1) | ||
|
||
_, err := AssignBlock(b1) | ||
|
||
if err != nil { | ||
t.Errorf("Could not insert valid block") | ||
} | ||
} |
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