Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

The following is based on https://github.com/lf-edge/eden/blob/master/tests/integration/controller_test.go#L11

// This context holds all the configuration items in the same
// way that Eden context works: the commands line options override
// YAML settings. In addition to that, context is polymorphic in
// a sense that it abstracts away a particular controller (currently
// Adam and Zedcloud are supported)
tc *EdenTestContext

// TestMain is used to provide setup and teardown for the rest of the
// tests. As part of setup we make sure that context has a slice of
// EVE instances that we can operate on. For any action, if the instance
// is not specified explicitly it is assumed to be the first one in the slice
func TestMain(m *testing.M) {
// this is expected to connect us to a desired controller and
// to an enterprise, all specified in the configuration file tc = GetNewTestContex(...)

// Create representation of EVE instances (based on external
// configuration) in the context. This is the first place
// where we're using zcli-like API:
for ... {
// this is modeled after: zcli edge-node create <name>
// --project=<project> --model=<model> [--title=<title>]
// ([--edge-node-certificate=<certificate>] |
// [--onboarding-certificate=<certificate>] |
// [(--onboarding-key=<key> --serial=<serial-number>)])
// [--network=<network>...]
//
// XXX: not sure if struct (giving us optional fields) would be better
edgeNode := tc.controller.NewEdgeNode("nameX", "default-project", ...)
}
os.Exit(m.Run()) }


func TestReboot(t *testing.T) {
// note that GetEdgeNode() without any argument is
// equivalent to the default (first one). Otherwise
// one can specify a name GetEdgeNode("foo")
edgeNode := tc.GetEdgeNode()

// this is modeled after: zcli edge-node reboot [-f] <name>
edgeNode.Reboot()

// this is how we make sure that the right event actually happens:
tc.AssertInfo("expected reboot to happen", func() {})

// now we're blocking until the time elapses or asserts fire
tc.WaitForAsserts(60) // this is guarantee to exit under 60 seconds
}




  • No labels