@@ -18,6 +18,7 @@ package main
18
18
19
19
import (
20
20
"bytes"
21
+ "encoding/json"
21
22
"fmt"
22
23
"os/exec"
23
24
"strings"
@@ -404,11 +405,89 @@ func TestSmokeGetRetention(t *testing.T) {
404
405
405
406
func TestActivateHotTier (t * testing.T ) {
406
407
CreateStream (t , NewGlob .QueryClient , NewGlob .Stream )
407
- activateHotTier (t )
408
- disableHotTier (t )
408
+ activateHotTier (t , "" , true )
409
+ disableHotTier (t , false )
409
410
DeleteStream (t , NewGlob .QueryClient , NewGlob .Stream )
410
411
}
411
412
413
+ func TestActivateNonExistentHotTier (t * testing.T ) {
414
+ if NewGlob .IngestorUrl .String () == "" {
415
+ t .Skip ("Skipping in standalone mode" )
416
+ }
417
+
418
+ status , _ := activateHotTier (t , "" , false )
419
+ require .NotEqualf (t , status , 200 , "Hot tier was activated for a non-existent stream." )
420
+ }
421
+
422
+ func TestHotTierWithTimePartition (t * testing.T ) {
423
+ time_partition_stream := NewGlob .Stream + "timepartition"
424
+ timeHeader := map [string ]string {"X-P-Time-Partition" : "source_time" , "X-P-Time-Partition-Limit" : "365d" }
425
+ CreateStreamWithHeader (t , NewGlob .QueryClient , time_partition_stream , timeHeader )
426
+
427
+ payload := StreamHotTier {
428
+ Size : "20 Gib" ,
429
+ }
430
+ jsonPayload , _ := json .Marshal (payload )
431
+
432
+ req , _ := NewGlob .QueryClient .NewRequest ("PUT" , "logstream/" + time_partition_stream + "/hottier" , bytes .NewBuffer (jsonPayload ))
433
+ req .Header .Set ("Content-Type" , "application/json" )
434
+ response , _ := NewGlob .QueryClient .Do (req )
435
+ body := readAsString (response .Body )
436
+
437
+ require .NotEqualf (t , response .StatusCode , 200 , "Hot tier activation succeeded for time partition with message: %s, but was expected to fail" , body )
438
+ }
439
+
440
+ func TestHotTierHugeDiskSize (t * testing.T ) {
441
+ if NewGlob .IngestorUrl .String () == "" {
442
+ t .Skip ("Skipping in standalone mode" )
443
+ }
444
+
445
+ CreateStream (t , NewGlob .QueryClient , NewGlob .Stream )
446
+ status , _ := activateHotTier (t , "500GiB" , false ) // activate hot tier with huge disk size
447
+ require .NotEqualf (t , status , 200 , "Hot tier was activated for a non-existent stream." )
448
+ DeleteStream (t , NewGlob .QueryClient , NewGlob .Stream )
449
+ }
450
+
451
+ func TestHotTierIncreaseSize (t * testing.T ) {
452
+ if NewGlob .IngestorUrl .String () == "" {
453
+ t .Skip ("Skipping in standalone mode" )
454
+ }
455
+
456
+ CreateStream (t , NewGlob .QueryClient , NewGlob .Stream )
457
+ activateHotTier (t , "" , true )
458
+ status , err := activateHotTier (t , "30 GiB" , false ) // increase disk size
459
+ require .Equalf (t , 200 , status , "Increasing disk size of hot tier failed with error: %s" , err )
460
+ DeleteStream (t , NewGlob .QueryClient , NewGlob .Stream )
461
+ }
462
+
463
+ func TestHotTierDecreaseSize (t * testing.T ) {
464
+ if NewGlob .IngestorUrl .String () == "" {
465
+ t .Skip ("Skipping in standalone mode" )
466
+ }
467
+
468
+ CreateStream (t , NewGlob .QueryClient , NewGlob .Stream )
469
+ activateHotTier (t , "" , true )
470
+ status , message := activateHotTier (t , "10 GiB" , false ) // decrease disk size
471
+ require .NotEqualf (t , 200 , status , "Decreasing disk size of hot tier should fail but succeeded with message: %s" , message )
472
+ DeleteStream (t , NewGlob .QueryClient , NewGlob .Stream )
473
+ }
474
+
475
+ func TestGetNonExistentHotTier (t * testing.T ) {
476
+ if NewGlob .IngestorUrl .String () == "" {
477
+ t .Skip ("Skipping in standalone mode" )
478
+ }
479
+
480
+ getHotTierStatus (t , true )
481
+ }
482
+
483
+ func DisableNonExistentHotTier (t * testing.T ) {
484
+ if NewGlob .IngestorUrl .String () == "" {
485
+ t .Skip ("Skipping in standalone mode" )
486
+ }
487
+
488
+ disableHotTier (t , true )
489
+ }
490
+
412
491
// create stream, put hot tier, ingest data for a duration, wait for 2-3 mins to see if all data is available in hot tier
413
492
func TestHotTierGetsLogs (t * testing.T ) {
414
493
if NewGlob .IngestorUrl .String () == "" {
@@ -417,11 +496,11 @@ func TestHotTierGetsLogs(t *testing.T) {
417
496
418
497
// DeleteStream(t, NewGlob.QueryClient, NewGlob.Stream)
419
498
createAndIngest (t )
420
- activateHotTier (t )
499
+ activateHotTier (t , "" , true )
421
500
time .Sleep (2 * 60 * time .Second ) // wait 2 minutes for hot tier to sync
422
501
423
502
htCount := QueryLogStreamCount (t , NewGlob .QueryClient , NewGlob .Stream , 200 )
424
- disableHotTier (t )
503
+ disableHotTier (t , false )
425
504
DeleteStream (t , NewGlob .QueryClient , NewGlob .Stream )
426
505
427
506
require .Equalf (t , htCount , `[{"count":200}]` , "Ingested 200 logs, but hot tier contains %s" , htCount )
@@ -441,11 +520,11 @@ func TestHotTierGetsLogsAfter(t *testing.T) {
441
520
442
521
// create a second stream with hot tier
443
522
createAndIngest (t )
444
- activateHotTier (t )
523
+ activateHotTier (t , "" , true )
445
524
time .Sleep (2 * 60 * time .Second ) // wait 2 minutes for hot tier to sync
446
525
447
526
htCount := QueryLogStreamCount (t , NewGlob .QueryClient , NewGlob .Stream , 200 )
448
- disableHotTier (t )
527
+ disableHotTier (t , false )
449
528
DeleteStream (t , NewGlob .QueryClient , NewGlob .Stream )
450
529
451
530
require .Equalf (t , prevCount , htCount , "With hot tier disabled, the count was %s but with it, the count is %s" , prevCount , htCount )
@@ -460,7 +539,7 @@ func TestHotTierLogCount(t *testing.T) {
460
539
createAndIngest (t )
461
540
countBefore := QueryLogStreamCount (t , NewGlob .QueryClient , NewGlob .Stream , 200 )
462
541
463
- activateHotTier (t )
542
+ activateHotTier (t , "" , true )
464
543
time .Sleep (60 * 2 * time .Second ) // wait for 2 minutes to allow hot tier to sync
465
544
466
545
countAfter := QueryLogStreamCount (t , NewGlob .QueryClient , NewGlob .Stream , 200 )
0 commit comments