@@ -61,6 +61,7 @@ describe('Linode lifecycle', () => {
6161 baseImageSnapshot : {
6262 enable : true ,
6363 } ,
64+ additionalLabels : [ 'test-label-1' , 'test-label-2' ] ,
6465 } , {
6566 sunshine : {
6667 enable : true ,
@@ -115,17 +116,63 @@ describe('Linode lifecycle', () => {
115116 }
116117 } ) . timeout ( 10000 )
117118
118- it ( 'should have a valid instance server output with existing server' , async ( ) => {
119+ it ( 'should have a valid instance server output with existing server and additional labels applied to instance and data disk ' , async ( ) => {
119120 const state = await getCurrentTestState ( )
121+ const linodeClient = getLinodeClient ( )
120122
121123 assert . ok ( state . provision . output ?. instanceServerId )
122124 const currentInstanceServerId = state . provision . output . instanceServerId
123125
124- const linodeClient = getLinodeClient ( )
125-
126+ // Check instance server status
126127 const serverStatus = await linodeClient . getInstanceStatus ( currentInstanceServerId )
127- // Instance should be in a valid state (running, stopped, etc.)
128- assert . equal ( serverStatus , 'running' )
128+ assert . equal ( serverStatus , 'running' , 'Instance should be running' )
129+
130+ // Verify instance has correct labels
131+ const instance = await linodeClient . getLinode ( currentInstanceServerId )
132+ assert . ok ( instance , 'Instance should exist' )
133+
134+ const expectedAdditionalLabels = [ 'test-label-1' , 'test-label-2' ]
135+ const actualTags = instance . tags || [ ]
136+
137+ // Check that all additional labels are present
138+ for ( const expectedLabel of expectedAdditionalLabels ) {
139+ assert . ok (
140+ actualTags . includes ( expectedLabel ) ,
141+ `Instance should have additional label '${ expectedLabel } '. Actual tags: ${ JSON . stringify ( actualTags ) } `
142+ )
143+ }
144+
145+ // Ensure there is at least one instance-name tag generated by Pulumi/linodeLabel
146+ assert . ok (
147+ actualTags . some ( tag => tag . startsWith ( 'instance-' ) ) ,
148+ `Instance should have an 'instance-' tag derived from instance name. Actual tags: ${ JSON . stringify ( actualTags ) } `
149+ )
150+
151+ // Verify data disk has correct labels
152+ assert . ok ( state . provision . output ?. dataDiskId , 'Data disk ID should be in output' )
153+ // dataDiskId is a filesystem path basename like "scsi-0Linode_Volume_my-instance-vol"
154+ // Extract the volume label by removing the "scsi-0Linode_Volume_" prefix
155+ const volumeLabel = state . provision . output . dataDiskId . replace ( / ^ s c s i - 0 L i n o d e _ V o l u m e _ / , '' )
156+ const volume = await linodeClient . getVolumeByLabel ( volumeLabel )
157+ assert . ok ( volume , 'Data volume should exist in Linode' )
158+
159+ // Expected additional labels from state
160+ const volumeExpectedTags = [ 'test-label-1' , 'test-label-2' ]
161+ const volumeActualTags = volume . tags || [ ]
162+
163+ // Check that all additional labels are present
164+ for ( const expectedTag of volumeExpectedTags ) {
165+ assert . ok (
166+ volumeActualTags . includes ( expectedTag ) ,
167+ `Data disk should have additional label '${ expectedTag } '. Actual tags: ${ JSON . stringify ( volumeActualTags ) } `
168+ )
169+ }
170+
171+ // Ensure there is at least one instance-name tag generated by Pulumi/linodeLabel
172+ assert . ok (
173+ volumeActualTags . some ( tag => tag . startsWith ( 'instance-' ) ) ,
174+ `Data disk should have an 'instance-' tag derived from instance name. Actual tags: ${ JSON . stringify ( volumeActualTags ) } `
175+ )
129176 } ) . timeout ( 10000 )
130177
131178 it ( 'should verify instance configuration after deployment' , async ( ) => {
@@ -152,7 +199,7 @@ describe('Linode lifecycle', () => {
152199 assert . ok ( dataDisk ) ;
153200 assert . strictEqual ( dataDisk . size , ( dataDiskSizeGb + 2 ) * 1024 * 1024 * 1024 ) ; // 2GB in bytes
154201
155- } ) . timeout ( 10000 )
202+ } ) . timeout ( 30 * 60 * 1000 ) // 30 minutes timeout, might be long
156203
157204 // run twice for idempotency
158205 for ( let i = 0 ; i < 2 ; i ++ ) {
0 commit comments