Skip to content

Commit

Permalink
Standarize some variable names and log formats
Browse files Browse the repository at this point in the history
Co-authored-by: iknite <[email protected]
  • Loading branch information
Jose Luis Lucas authored and iknite committed Dec 18, 2018
1 parent 9fc78bc commit 2b5e1cd
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 34 deletions.
3 changes: 2 additions & 1 deletion cmd/agent_auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func newAgentAuditorCommand(ctx *agentContext) *cobra.Command {

cmd.Flags().StringSliceVarP(&qedUrls, "qedUrls", "", []string{}, "Comma-delimited list of QED servers ([host]:port), through which an auditor can make queries")
cmd.Flags().StringSliceVarP(&pubUrls, "pubUrls", "", []string{}, "Comma-delimited list of QED servers ([host]:port), through which an auditor can make queries")
cmd.MarkFlagRequired("endpoints")
cmd.MarkFlagRequired("qedUrls")
cmd.MarkFlagRequired("pubUrls")

return cmd
}
2 changes: 1 addition & 1 deletion cmd/agent_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func newAgentMonitorCommand(ctx *agentContext) *cobra.Command {
agentConfig.Role = member.Monitor
monitorConfig := monitor.DefaultConfig()
monitorConfig.APIKey = apiKey
monitorConfig.QEDEndpoints = qedUrls
monitorConfig.QedUrls = qedUrls
monitorConfig.PubUrls = pubUrls

monitor, err := monitor.NewMonitor(monitorConfig)
Expand Down
3 changes: 1 addition & 2 deletions gossip/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func (m *Monitor) sendAlert(msg string) {

func (m *Monitor) executeTask(task *QueryTask) {
log.Debug("Executing task: %+v", task)
fmt.Printf("Executing task: %+v\n", task)
resp, err := m.client.Incremental(task.Start, task.End)
if err != nil {
// retry
Expand All @@ -160,5 +159,5 @@ func (m *Monitor) executeTask(task *QueryTask) {
log.Infof("Unable to verify incremental proof from %d to %d",
task.StartSnapshot.Version, task.EndSnapshot.Version)
}
fmt.Printf("Consistency between versions %d and %d: %v\n", task.Start, task.End, ok)
log.Debugf("Consistency between versions %d and %d: %v\n", task.Start, task.End, ok)
}
14 changes: 6 additions & 8 deletions tests/e2e/agents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func TestAgents(t *testing.T) {
bPublisher, aPublisher := setupPublisher(0, t)

scenario, let := scope.Scope(t,
merge(bStore, bServer, bAuditor, bMonitor, bPublisher),
merge(aAuditor, aMonitor, aPublisher, aServer, aStore),
merge(bStore, bServer, bPublisher, bAuditor, bMonitor),
merge(aServer, aPublisher, aAuditor, aMonitor, aStore),
)

client := getClient(0)
Expand Down Expand Up @@ -124,15 +124,14 @@ func TestAgents(t *testing.T) {
cmd := exec.Command("curl",
"-sS",
"-XDELETE",
"-H", "Api-Key: my-key",
"-H", fmt.Sprintf("Api-Key:%s", APIKey),
"-H", "Content-type: application/json",
"http://localhost:8081/tamper",
QEDTamperURL,
"-d", fmt.Sprintf(`{"Digest": "%X"}`, hashing.NewSha256Hasher().Do(hashing.Digest(event))),
)

_, err := cmd.CombinedOutput()
assert.NoError(t, err, "Subprocess must not exit with status 1")

})

let("Check Auditor alerts", func(t *testing.T) {
Expand All @@ -148,7 +147,6 @@ func TestAgents(t *testing.T) {
assert.NoError(t, err)
assert.False(t, strings.Contains(string(alerts), "Unable to verify incremental"), "Must not exist monitor alert")
})

})

// scenario("Add 1st event. Tamper it. Add 2nd event. Check monitor alerts correctly", func() {
Expand All @@ -163,9 +161,9 @@ func TestAgents(t *testing.T) {
// cmd := exec.Command("curl",
// "-sS",
// "-XDELETE",
// "-H", "Api-Key: my-key",
// "-H", fmt.Sprintf("Api-Key:%s", APIKey),
// "-H", "Content-type: application/json",
// "http://localhost:8081/tamper",
// QEDTamperURL,
// "-d", fmt.Sprintf(`{"Digest": "%X"}`, hashing.NewSha256Hasher().Do(hashing.Digest(event))),
// )

Expand Down
14 changes: 7 additions & 7 deletions tests/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ import (

func TestCli(t *testing.T) {
before, after := setupServer(0, "", t)
scenario, let := scope.Scope(t, before, after)
scenario, let := scope.Scope(t, before, merge(after))

scenario("Add one event through cli and verify it", func() {

let("Add event", func(t *testing.T) {
cmd := exec.Command("go",
"run",
"./../../main.go",
"--apikey=my-key",
fmt.Sprintf("--apikey=%s", APIKey),
"client",
"--endpoint=http://localhost:8500",
fmt.Sprintf("--endpoint=%s", QEDUrl),
"add",
"--key='test event'",
"--value=2",
Expand All @@ -55,9 +55,9 @@ func TestCli(t *testing.T) {
cmd := exec.Command("go",
"run",
"./../../main.go",
"--apikey=my-key",
fmt.Sprintf("--apikey=%s", APIKey),
"client",
"--endpoint=http://localhost:8500",
fmt.Sprintf("--endpoint=%s", QEDUrl),
"membership",
"--hyperDigest=81ae2d8f6ecec9c5837d12a09e3b42a1c880b6c77f81ff1f85aef36dac4fdf6a",
"--historyDigest=0f5129eaf5dbfb1405ff072a04d716aaf4e4ba4247a3322c41582e970dbb7b00",
Expand All @@ -79,9 +79,9 @@ func TestCli(t *testing.T) {
cmd := exec.Command("go",
"run",
"./../../main.go",
"--apikey=my-key",
fmt.Sprintf("--apikey=%s", APIKey),
"client",
"--endpoint=http://localhost:8500",
fmt.Sprintf("--endpoint=%s", QEDUrl),
"membership",
"--hyperDigest=81ae2d8f6ecec9c5837d12a09e3b42a1c880b6c77f81ff1f85aef36dac4fdf6a",
"--historyDigest=0f5129eaf5dbfb1405ff072a04d716aaf4e4ba4247a3322c41582e970dbb7b00",
Expand Down
15 changes: 8 additions & 7 deletions tests/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ var apiKey, storageType, keyFile string
var cacheSize uint64

const (
QEDUrl = "http://127.0.0.1:8080"
StoreUrl = "http://127.0.0.1:8888"
APIKey = "my-key"
QEDGossip = "127.0.0.1:9010"
QEDUrl = "http://127.0.0.1:8080"
QEDGossip = "127.0.0.1:9010"
QEDTamperURL = "http://localhost:8081/tamper"
StoreUrl = "http://127.0.0.1:8888"
APIKey = "my-key"
)

func init() {
Expand Down Expand Up @@ -110,7 +111,7 @@ func setupAuditor(id int, t *testing.T) (scope.TestF, scope.TestF) {
after := func(t *testing.T) {
if au != nil {
au.Shutdown()
agent.Shutdown()
_ = agent.Shutdown()
} else {
t.Fatalf("Unable to shutdown the auditor!")
}
Expand Down Expand Up @@ -140,7 +141,7 @@ func setupMonitor(id int, t *testing.T) (scope.TestF, scope.TestF) {
after := func(t *testing.T) {
if mn != nil {
mn.Shutdown()
agent.Shutdown()
_ = agent.Shutdown()
} else {
t.Fatalf("Unable to shutdown the monitor!")
}
Expand Down Expand Up @@ -168,7 +169,7 @@ func setupPublisher(id int, t *testing.T) (scope.TestF, scope.TestF) {
after := func(t *testing.T) {
if pu != nil {
pu.Shutdown()
agent.Shutdown()
_ = agent.Shutdown()
} else {
t.Fatalf("Unable to shutdown the publisher!")
}
Expand Down
16 changes: 8 additions & 8 deletions tests/gossip/run_gossip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

masterEndpoint="127.0.0.1:9100"
publisherEndpoint="http://127.0.0.1:8888"
alertsEndpoint="http://127.0.0.1:8888"
qedEndpoint="http://127.0.0.1:8080"
qedGossipEndpoint="127.0.0.1:9100"
snapshotStoreEndpoint="http://127.0.0.1:8888"
alertsStoreEndpoint="http://127.0.0.1:8888"
qedHTTPEndpoint="http://127.0.0.1:8080"
keyFile="/var/tmp/id_ed25519"
QED="go run $GOPATH/src/github.com/bbva/qed/main.go"

Expand All @@ -23,25 +23,25 @@ if [ ! -f "$keyFile" ]; then
echo -e 'y\n' | ssh-keygen -t ed25519 -N '' -f /var/tmp/id_ed25519
fi

$QED start -k key -l silent --node-id server0 --gossip-addr $masterEndpoint --raft-addr 127.0.0.1:9000 -y $keyFile &
$QED start -k key -l silent --node-id server0 --gossip-addr $qedGossipEndpoint --raft-addr 127.0.0.1:9000 -y $keyFile &
pids[0]=$!
sleep 2s

for i in `seq 1 $1`;
do
xterm -hold -e "$QED agent --alertsUrls $alertsEndpoint auditor -k key -l info --bind 127.0.0.1:910$i --join $masterEndpoint --qedUrls $qedEndpoint --pubUrls $publisherEndpoint --node auditor$i" &
xterm -hold -e "$QED agent --alertsUrls $alertsStoreEndpoint auditor -k key -l info --bind 127.0.0.1:910$i --join $qedGossipEndpoint --qedUrls $qedHTTPEndpoint --pubUrls $snapshotStoreEndpoint --node auditor$i" &
pids+=($!)
done

for i in `seq 1 $2`;
do
xterm -hold -e "$QED agent --alertsUrls $alertsEndpoint monitor -k key -l info --bind 127.0.0.1:920$i --join $masterEndpoint --endpoints $qedEndpoint --pubUrls $publisherEndpoint --node monitor$i" &
xterm -hold -e "$QED agent --alertsUrls $alertsStoreEndpoint monitor -k key -l info --bind 127.0.0.1:920$i --join $qedGossipEndpoint --qedUrls $qedHTTPEndpoint --pubUrls $snapshotStoreEndpoint --node monitor$i" &
pids+=($!)
done

for i in `seq 1 $3`;
do
xterm -hold -e "$QED agent --alertsUrls $alertsEndpoint publisher -k key -l info --bind 127.0.0.1:930$i --join $masterEndpoint --endpoints $publisherEndpoint --node publisher$i" &
xterm -hold -e "$QED agent --alertsUrls $alertsStoreEndpoint publisher -k key -l info --bind 127.0.0.1:930$i --join $qedGossipEndpoint --endpoints $snapshotStoreEndpoint --node publisher$i" &
pids+=($!)
done

Expand Down

0 comments on commit 2b5e1cd

Please sign in to comment.