Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1261)

Side by Side Diff: juju/testing/instance.go

Issue 77490043: environs: Added Networks to StartInstanceParams
Patch Set: Created 10 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « environs/broker.go ('k') | provider/common/bootstrap_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package testing 4 package testing
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 8
9 gc "launchpad.net/gocheck" 9 gc "launchpad.net/gocheck"
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 // StartInstanceWithConstraints is a test helper function that starts an instanc e 80 // StartInstanceWithConstraints is a test helper function that starts an instanc e
81 // with the given constraints, and a plausible but invalid configuration, and re turns 81 // with the given constraints, and a plausible but invalid configuration, and re turns
82 // the result of Environ.StartInstance. 82 // the result of Environ.StartInstance.
83 func StartInstanceWithConstraints( 83 func StartInstanceWithConstraints(
84 env environs.Environ, machineId string, cons constraints.Value, 84 env environs.Environ, machineId string, cons constraints.Value,
85 ) ( 85 ) (
86 instance.Instance, *instance.HardwareCharacteristics, error, 86 instance.Instance, *instance.HardwareCharacteristics, error,
87 ) { 87 ) {
88 return StartInstanceWithConstraintsAndNetworks(env, machineId, cons, env irons.Networks{})
89 }
90
91 // AssertStartInstanceWithNetworks is a test helper function that starts an
92 // instance with the given networks, and a plausible but invalid
93 // configuration, and returns the result of Environ.StartInstance.
94 func AssertStartInstanceWithNetworks(
95 c *gc.C, env environs.Environ, machineId string, cons constraints.Value, nets environs.Networks,
96 ) (
97 instance.Instance, *instance.HardwareCharacteristics,
98 ) {
99 inst, hc, err := StartInstanceWithConstraintsAndNetworks(env, machineId, cons, nets)
100 c.Assert(err, gc.IsNil)
101 return inst, hc
102 }
103
104 // StartInstanceWithNetworks is a test helper function that starts an instance
105 // with the given networks, and a plausible but invalid configuration, and
106 // returns the result of Environ.StartInstance.
107 func StartInstanceWithConstraintsAndNetworks(
108 env environs.Environ, machineId string, cons constraints.Value,
109 nets environs.Networks,
110 ) (
111 instance.Instance, *instance.HardwareCharacteristics, error,
112 ) {
88 series := env.Config().DefaultSeries() 113 series := env.Config().DefaultSeries()
89 agentVersion, ok := env.Config().AgentVersion() 114 agentVersion, ok := env.Config().AgentVersion()
90 if !ok { 115 if !ok {
91 return nil, nil, fmt.Errorf("missing agent version in environmen t config") 116 return nil, nil, fmt.Errorf("missing agent version in environmen t config")
92 } 117 }
93 possibleTools, err := tools.FindInstanceTools(env, agentVersion, series, cons.Arch) 118 possibleTools, err := tools.FindInstanceTools(env, agentVersion, series, cons.Arch)
94 if err != nil { 119 if err != nil {
95 return nil, nil, err 120 return nil, nil, err
96 } 121 }
97 machineNonce := "fake_nonce" 122 machineNonce := "fake_nonce"
98 stateInfo := FakeStateInfo(machineId) 123 stateInfo := FakeStateInfo(machineId)
99 apiInfo := FakeAPIInfo(machineId) 124 apiInfo := FakeAPIInfo(machineId)
100 machineConfig := environs.NewMachineConfig(machineId, machineNonce, stat eInfo, apiInfo) 125 machineConfig := environs.NewMachineConfig(machineId, machineNonce, stat eInfo, apiInfo)
101 return env.StartInstance(environs.StartInstanceParams{ 126 return env.StartInstance(environs.StartInstanceParams{
102 Constraints: cons, 127 Constraints: cons,
128 Networks: nets,
103 Tools: possibleTools, 129 Tools: possibleTools,
104 MachineConfig: machineConfig, 130 MachineConfig: machineConfig,
105 }) 131 })
106 } 132 }
OLDNEW
« no previous file with comments | « environs/broker.go ('k') | provider/common/bootstrap_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b