Files
go-ethereum/simulation/examples/snapshot/docker_test.go
Rafael Matias 388d8ccd9f PoC: Network simulation framework (#1555)
* simv2: wip

* simulation: exec adapter start/stop

* simulation: add node status to exec adapter

* simulation: initial simulation code

* simulation: exec adapter, configure path to executable

* simulation: initial docker adapter

* simulation: wip kubernetes adapter

* simulation: kubernetes adapter proxy

* simulation: implement GetAll/StartAll/StopAll

* simulation: kuberentes adapter - set env vars and resource limits

* simulation: discovery test

* simulation: remove port definitions within docker adapter

* simulation: simplify wait for healthy loop

* simulation: get nat ip addr from interface

* simulation: pull docker images automatically

* simulation: NodeStatus -> NodeInfo

* simulation: move discovery test to example dir

* simulation: example snapshot usage

* simulation: add goclient specific simulation

* simulation: add peer connections to snapshot

* simulation: close rpc client

* simulation: don't export kubernetes proxy server

* simulation: merge simulation code

* simulation: don't export nodemap

* simulation: rename SimulationSnapshot -> Snapshot

* simulation: linting fixes

* simulation: add k8s available helper func

* simulation: vendor

* simulation: fix 'no non-test Go files' when building

* simulation: remove errors from interface methods where non were returned

* simulation: run getHealthInfo check in parallel
2019-07-24 17:00:13 +02:00

56 lines
1.1 KiB
Go

package snapshot
import (
"fmt"
"testing"
"github.com/ethersphere/swarm/simulation"
)
func TestDockerSnapshotFromFile(t *testing.T) {
snap, err := simulation.LoadSnapshotFromFile("docker.json")
if err != nil {
t.Fatal(err)
}
if !simulation.IsDockerAvailable(snap.DefaultAdapter.Config.(simulation.DockerAdapterConfig).DaemonAddr) {
t.Skip("docker is not available, skipping test")
}
sim, err := simulation.NewSimulationFromSnapshot(snap)
if err != nil {
t.Fatal(err)
}
defer func() {
err = sim.StopAll()
if err != nil {
t.Error(err)
}
}()
nodes := sim.GetAll()
if len(nodes) != len(snap.Nodes) {
t.Fatalf("Got %d . Expected %d nodes", len(nodes), len(snap.Nodes))
}
// Check hive output on the first node
node, err := sim.Get(simulation.NodeID("test-0"))
if err != nil {
t.Error(err)
}
client, err := sim.RPCClient(node.Info().ID)
if err != nil {
t.Errorf("Failed to get rpc client: %v", err)
}
var hive string
err = client.Call(&hive, "bzz_hive")
if err != nil {
t.Errorf("could not get hive info: %v", err)
}
fmt.Println(hive)
}