Beispiel #1
0
		worker: worker,
		closer: closer,
	}
}

func (c *closeWorker) Kill() {
	c.worker.Kill()
}

func (c *closeWorker) Wait() error {
	err := c.worker.Wait()
	if err := c.closer.Close(); err != nil {
		log.Errorf("closeWorker: close error: %v", err)
	}
	return err
}

// newDeployContext gives the tests the opportunity to create a deployer.Context
// that can be used for testing so as to avoid (1) deploying units to the system
// running the tests and (2) get access to the *State used internally, so that
// tests can be run without waiting for the 5s watcher refresh time to which we would
// otherwise be restricted.
var newDeployContext = func(st *state.State, dataDir string) deployer.Context {
	return deployer.NewSimpleContext(dataDir, st.CACert(), st)
}

func newDeployer(st *state.State, machineId string, dataDir string) *deployer.Deployer {
	ctx := newDeployContext(st, dataDir)
	return deployer.NewDeployer(st, ctx, machineId)
}
Beispiel #2
0
}

func (c *closeWorker) Wait() error {
	err := c.worker.Wait()
	if err := c.closer.Close(); err != nil {
		log.Errorf("closeWorker: close error: %v", err)
	}
	return err
}

// newDeployContext gives the tests the opportunity to create a deployer.Context
// that can be used for testing so as to avoid (1) deploying units to the system
// running the tests and (2) get access to the *State used internally, so that
// tests can be run without waiting for the 5s watcher refresh time to which we would
// otherwise be restricted.
var newDeployContext = func(st *apideployer.State, dataDir string) (deployer.Context, error) {
	caCert, err := st.CACert()
	if err != nil {
		return nil, err
	}
	return deployer.NewSimpleContext(dataDir, caCert, st), nil
}

func newDeployer(st *apideployer.State, machineTag string, dataDir string) (worker.Worker, error) {
	ctx, err := newDeployContext(st, dataDir)
	if err != nil {
		return nil, err
	}
	return deployer.NewDeployer(st, ctx, machineTag), nil
}