Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cs733
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sushant Mahajan
cs733
Commits
60731d30
Commit
60731d30
authored
Feb 09, 2015
by
Harshit Pande
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
noreply test cases
parent
2099c0f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
37 deletions
+17
-37
assignment2/src/runner.go
assignment2/src/runner.go
+0
-35
assignment2/src/server_test.go
assignment2/src/server_test.go
+17
-2
No files found.
assignment2/src/runner.go
deleted
100644 → 0
View file @
2099c0f1
package
main
import
(
"fmt"
"os"
"os/exec"
"strconv"
)
//constant values used
const
(
NUM_SERVERS
int
=
5
)
func
TestServersCommunic
(
i
int
)
{
cmd
:=
exec
.
Command
(
"go"
,
"run"
,
"server.go"
,
strconv
.
Itoa
(
i
+
1
),
strconv
.
Itoa
(
NUM_SERVERS
))
f
,
err
:=
os
.
OpenFile
(
strconv
.
Itoa
(
i
),
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0666
)
if
err
!=
nil
{
fmt
.
Println
(
"error opening file: %v"
,
err
)
}
defer
f
.
Close
()
cmd
.
Stdout
=
f
cmd
.
Stderr
=
f
cmd
.
Run
()
}
func
main
()
{
for
i
:=
0
;
i
<
NUM_SERVERS
;
i
++
{
go
TestServersCommunic
(
i
)
}
var
dummy_input
string
fmt
.
Scanln
(
&
dummy_input
)
}
assignment2/src/server_test.go
View file @
60731d30
...
...
@@ -81,15 +81,30 @@ func testConnectFollower(t *testing.T) {
//noreply option is not more valid with set and cas
//client should get command error from the server if it sends 'no reply' option
func
testNoReply
(
t
*
testing
.
T
)
{
var
noreply_cases
=
[]
t
estpair
{
var
noreply_cases
=
[]
T
estpair
{
{[]
byte
(
"set mykey1 100 3 noreply
\r\n
"
),
[]
byte
(
"ERRCMDERR
\r\n
"
)},
{[]
byte
(
"cas mykey1 0 1 6 noreply
\r\n
"
),
[]
byte
(
"ERRCMDERR
\r\n
"
)},
}
server_port
:=
raft
.
CLIENT_PORT
+
1
conn
,
err
:=
net
.
Dial
(
"tcp"
,
":"
+
strconv
.
Itoa
(
server_port
))
if
err
!=
nil
{
t
.
Error
(
"Error in connecting the server at port: "
+
strconv
.
Itoa
(
server_port
))
}
else
{
time
.
Sleep
(
time
.
Millisecond
)
for
_
,
pair
:=
range
noreply_cases
{
conn
.
Write
(
pair
.
to_server
)
buffer
:=
make
([]
byte
,
1024
)
conn
.
Read
(
buffer
)
n
:=
bytes
.
Index
(
buffer
,
[]
byte
{
0
})
if
!
bytes
.
Equal
(
buffer
[
:
n
],
pair
.
from_server
)
{
t
.
Error
(
"For"
,
pair
.
to_server
,
string
(
pair
.
to_server
),
"expected"
,
pair
.
from_server
,
string
(
pair
.
from_server
),
"got"
,
buffer
[
:
n
],
string
(
buffer
[
:
n
]),
)
}
}
conn
.
Close
()
time
.
Sleep
(
time
.
Millisecond
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment