3131import feast .proto .serving .ServingAPIProto ;
3232import feast .proto .serving .ServingServiceGrpc ;
3333import feast .proto .types .ValueProto ;
34+ import io .grpc .ManagedChannel ;
3435import java .io .ByteArrayOutputStream ;
3536import java .io .File ;
3637import java .io .IOException ;
4849import org .apache .avro .io .Encoder ;
4950import org .apache .avro .io .EncoderFactory ;
5051import org .junit .ClassRule ;
52+ import org .junit .jupiter .api .AfterAll ;
5153import org .junit .jupiter .api .BeforeAll ;
5254import org .junit .jupiter .api .Test ;
5355import org .springframework .boot .test .context .SpringBootTest ;
@@ -187,12 +189,13 @@ static void globalSetup() throws IOException {
187189 // Single Entity Cassandra Table
188190 cqlSession .execute (
189191 String .format (
190- "CREATE TABLE %s.%s (key BLOB PRIMARY KEY, schema_ref BLOB);" ,
191- CASSANDRA_KEYSPACE , cassandraTableName ));
192+ "CREATE TABLE %s.%s (key BLOB PRIMARY KEY);" , CASSANDRA_KEYSPACE , cassandraTableName ));
192193
193194 // Add column families
194195 cqlSession .execute (
195- String .format ("ALTER TABLE %s.%s ADD rides BLOB;" , CASSANDRA_KEYSPACE , cassandraTableName ));
196+ String .format (
197+ "ALTER TABLE %s.%s ADD (%s BLOB, %s__schema_ref BLOB);" ,
198+ CASSANDRA_KEYSPACE , cassandraTableName , ridesFeatureTableName , ridesFeatureTableName ));
196199
197200 /** Single Entity Ingestion Workflow */
198201 Schema ftSchema =
@@ -216,14 +219,18 @@ static void globalSetup() throws IOException {
216219 .build ();
217220 byte [] entityFeatureKey =
218221 String .valueOf (DataGenerator .createInt64Value (1 ).getInt64Val ()).getBytes ();
219- byte [] entityFeatureValue = createEntityValue (ftSchema , schemaReference , record );
222+ byte [] entityFeatureValue = createEntityValue (ftSchema , record );
220223 byte [] schemaKey = createSchemaKey (schemaReference );
221224
222225 PreparedStatement statement =
223226 cqlSession .prepare (
224227 String .format (
225- "INSERT INTO %s.%s (key, schema_ref, rides) VALUES (?, ?, ?)" ,
226- CASSANDRA_KEYSPACE , cassandraTableName ));
228+ "INSERT INTO %s.%s (%s, %s__schema_ref, %s) VALUES (?, ?, ?)" ,
229+ CASSANDRA_KEYSPACE ,
230+ cassandraTableName ,
231+ CASSANDRA_ENTITY_KEY ,
232+ ridesFeatureTableName ,
233+ ridesFeatureTableName ));
227234 cqlSession .execute (
228235 statement .bind (
229236 ByteBuffer .wrap (entityFeatureKey ),
@@ -262,14 +269,11 @@ private static byte[] createSchemaKey(byte[] schemaReference) throws IOException
262269 return schemaKey ;
263270 }
264271
265- private static byte [] createEntityValue (
266- Schema schema , byte [] schemaReference , GenericRecord record ) throws IOException {
272+ private static byte [] createEntityValue (Schema schema , GenericRecord record ) throws IOException {
267273 // Entity-Feature Row
268274 byte [] avroSerializedFeatures = recordToAvro (record , schema );
269275
270276 ByteArrayOutputStream concatOutputStream = new ByteArrayOutputStream ();
271- concatOutputStream .write (schemaReference );
272- concatOutputStream .write ("" .getBytes ());
273277 concatOutputStream .write (avroSerializedFeatures );
274278 byte [] entityFeatureValue = concatOutputStream .toByteArray ();
275279
@@ -286,6 +290,11 @@ private static byte[] recordToAvro(GenericRecord datum, Schema schema) throws IO
286290 return output .toByteArray ();
287291 }
288292
293+ @ AfterAll
294+ static void tearDown () {
295+ ((ManagedChannel ) servingStub .getChannel ()).shutdown ();
296+ }
297+
289298 @ Test
290299 public void shouldRegisterSingleEntityAndGetOnlineFeatures () {
291300 String projectName = "default" ;
0 commit comments