@@ -225,7 +225,7 @@ private ObjectInfo validateObjectInfo(ObjectInfo oi, String bucket, String objec
225
225
}
226
226
227
227
@ SuppressWarnings ("SameParameterValue" )
228
- private static Object [] getInput (int size ) throws IOException {
228
+ private static Object [] getInput (int size ) {
229
229
File found = null ;
230
230
long foundLen = Long .MAX_VALUE ;
231
231
final String classPath = System .getProperty ("java.class.path" , "." );
@@ -618,4 +618,59 @@ private void validateWatcher(Object[] expecteds, TestObjectStoreWatcher watcher)
618
618
}
619
619
}
620
620
}
621
+
622
+ @ Test
623
+ public void testObjectStoreDomains () throws Exception {
624
+ runInJsHubLeaf ((hubNc , leafNc ) -> {
625
+ ObjectStoreManagement hubOsm = hubNc .objectStoreManagement ();
626
+
627
+ // Create main OS on HUB
628
+ String hubBucket = bucket ();
629
+ ObjectStoreStatus hubStatus = hubOsm .create (ObjectStoreConfiguration .builder ()
630
+ .name (hubBucket )
631
+ .storageType (StorageType .Memory )
632
+ .replicas (1 )
633
+ .build ());
634
+ assertEquals (0 , hubStatus .getSize ());
635
+ assertEquals (1 , hubStatus .getReplicas ());
636
+
637
+ ObjectStore hubOs = hubNc .objectStore (hubBucket );
638
+ ObjectStore leafOs = leafNc .objectStore (hubBucket , ObjectStoreOptions .builder ().jsDomain (HUB_DOMAIN ).build ());
639
+
640
+ String objectName = name ();
641
+ ObjectMeta meta = ObjectMeta .builder (objectName )
642
+ .chunkSize (8 * 1024 )
643
+ .build ();
644
+
645
+ Object [] input = getInput (4 * 8 * 1024 );
646
+ File file = (File )input [1 ];
647
+ InputStream in = Files .newInputStream (file .toPath ());
648
+ hubOs .put (meta , in );
649
+
650
+ hubStatus = hubOs .getStatus ();
651
+ assertTrue (hubStatus .getSize () > 0 );
652
+
653
+ ObjectStoreStatus leafStatus = leafOs .getStatus ();
654
+
655
+ assertEquals (hubStatus .getBucketName (), leafStatus .getBucketName ());
656
+ assertEquals (hubStatus .getSize (), leafStatus .getSize ());
657
+
658
+ ObjectInfo hubInfo = hubOs .getInfo (objectName );
659
+ ObjectInfo leafInfo = leafOs .getInfo (objectName );
660
+
661
+ assertEquals (hubInfo .getNuid (), leafInfo .getNuid ());
662
+ assertEquals (hubInfo .getSize (), leafInfo .getSize ());
663
+ assertEquals (hubInfo .getObjectMeta ().getObjectName (), leafInfo .getObjectMeta ().getObjectName ());
664
+
665
+ ByteArrayOutputStream hubOut = new ByteArrayOutputStream ();
666
+ ByteArrayOutputStream leafOut = new ByteArrayOutputStream ();
667
+ hubOs .get (objectName , hubOut );
668
+ leafOs .get (objectName , leafOut );
669
+
670
+ byte [] hubBytes = hubOut .toByteArray ();
671
+ byte [] leafBytes = leafOut .toByteArray ();
672
+
673
+ assertArrayEquals (hubBytes , leafBytes );
674
+ });
675
+ }
621
676
}
0 commit comments