@@ -48,12 +48,12 @@ func TestConvertCloudProperties(t *testing.T) {
4848 want * metadataserver.CloudProperties
4949 }{
5050 {
51- name : "nil cloud properties " ,
51+ name : "NilCloudProperties " ,
5252 cp : nil ,
5353 want : nil ,
5454 },
5555 {
56- name : "non-nil cloud properties " ,
56+ name : "NonNilCloudProperties " ,
5757 cp : & cpb.CloudProperties {
5858 ProjectId : "test-project" ,
5959 NumericProjectId : "12345" ,
@@ -95,32 +95,35 @@ func TestOracleCommandKey(t *testing.T) {
9595 tests := []struct {
9696 name string
9797 cmd * gapb.Command
98+ cp * metadataserver.CloudProperties
9899 wantKey string
99100 wantTimeout time.Duration
100101 wantLock bool
101102 }{
102103 {
103- name : "nil agent command " ,
104+ name : "NilAgentCommand " ,
104105 cmd : & gapb.Command {},
106+ cp : & metadataserver.CloudProperties {InstanceID : "test-instance" },
105107 wantKey : "" ,
106108 wantTimeout : 0 ,
107109 wantLock : false ,
108110 },
109111 {
110- name : "nil parameters " ,
112+ name : "NilParameters " ,
111113 cmd : & gapb.Command {
112114 CommandType : & gapb.Command_AgentCommand {
113115 AgentCommand : & gapb.AgentCommand {
114116 Command : "oracle_start_database" ,
115117 },
116118 },
117119 },
120+ cp : & metadataserver.CloudProperties {InstanceID : "test-instance" },
118121 wantKey : "" ,
119122 wantTimeout : 0 ,
120123 wantLock : false ,
121124 },
122125 {
123- name : "empty parameters " ,
126+ name : "EmptyParameters " ,
124127 cmd : & gapb.Command {
125128 CommandType : & gapb.Command_AgentCommand {
126129 AgentCommand : & gapb.AgentCommand {
@@ -129,12 +132,13 @@ func TestOracleCommandKey(t *testing.T) {
129132 },
130133 },
131134 },
135+ cp : & metadataserver.CloudProperties {InstanceID : "test-instance" },
132136 wantKey : "" ,
133137 wantTimeout : 0 ,
134138 wantLock : false ,
135139 },
136140 {
137- name : "missing oracle_home " ,
141+ name : "MissingOracleHome " ,
138142 cmd : & gapb.Command {
139143 CommandType : & gapb.Command_AgentCommand {
140144 AgentCommand : & gapb.AgentCommand {
@@ -145,12 +149,13 @@ func TestOracleCommandKey(t *testing.T) {
145149 },
146150 },
147151 },
152+ cp : & metadataserver.CloudProperties {InstanceID : "test-instance" },
148153 wantKey : "" ,
149154 wantTimeout : 0 ,
150155 wantLock : false ,
151156 },
152157 {
153- name : "missing oracle_sid " ,
158+ name : "MissingOracleSID " ,
154159 cmd : & gapb.Command {
155160 CommandType : & gapb.Command_AgentCommand {
156161 AgentCommand : & gapb.AgentCommand {
@@ -161,12 +166,13 @@ func TestOracleCommandKey(t *testing.T) {
161166 },
162167 },
163168 },
169+ cp : & metadataserver.CloudProperties {InstanceID : "test-instance" },
164170 wantKey : "" ,
165171 wantTimeout : 0 ,
166172 wantLock : false ,
167173 },
168174 {
169- name : "with oracle_sid and oracle_home " ,
175+ name : "SIDAndHome_NilCloudProperties " ,
170176 cmd : & gapb.Command {
171177 CommandType : & gapb.Command_AgentCommand {
172178 AgentCommand : & gapb.AgentCommand {
@@ -178,17 +184,36 @@ func TestOracleCommandKey(t *testing.T) {
178184 },
179185 },
180186 },
181- wantKey : "orcl:/u01/app/oracle/product/19.3.0/dbhome_1" ,
187+ cp : nil ,
188+ wantKey : "" ,
189+ wantTimeout : 0 ,
190+ wantLock : false ,
191+ },
192+ {
193+ name : "SIDAndHome_CloudProperties" ,
194+ cmd : & gapb.Command {
195+ CommandType : & gapb.Command_AgentCommand {
196+ AgentCommand : & gapb.AgentCommand {
197+ Command : "oracle_health_check" ,
198+ Parameters : map [string ]string {
199+ "oracle_sid" : "orcl" ,
200+ "oracle_home" : "/u01/app/oracle/product/19.3.0/dbhome_1" ,
201+ },
202+ },
203+ },
204+ },
205+ cp : & metadataserver.CloudProperties {InstanceID : "test-instance" },
206+ wantKey : "test-instance:/u01/app/oracle/product/19.3.0/dbhome_1:orcl" ,
182207 wantTimeout : 24 * time .Hour ,
183208 wantLock : true ,
184209 },
185210 }
186211
187212 for _ , tc := range tests {
188213 t .Run (tc .name , func (t * testing.T ) {
189- gotKey , gotTimeout , gotLock := oracleCommandKey (tc .cmd )
214+ gotKey , gotTimeout , gotLock := oracleCommandKey (context . Background (), tc .cmd , tc . cp )
190215 if gotKey != tc .wantKey || gotTimeout != tc .wantTimeout || gotLock != tc .wantLock {
191- t .Errorf ("oracleCommandKey(%v) = (%q, %v, %v), want (%q, %v, %v)" , tc .cmd , gotKey , gotTimeout , gotLock , tc .wantKey , tc .wantTimeout , tc .wantLock )
216+ t .Errorf ("oracleCommandKey(%v, %v ) = (%q, %v, %v), want (%q, %v, %v)" , tc .cmd , tc . cp , gotKey , gotTimeout , gotLock , tc .wantKey , tc .wantTimeout , tc .wantLock )
192217 }
193218 })
194219 }
0 commit comments