Ejemplo n.º 1
0
        public async Task VeryLargeRuntimeStateConverterTest()
        {
            string veryLargeInput = TestUtils.GenerateRandomString(20 * 1024);
            OrchestrationRuntimeState newOrchestrationRuntimeStateLarge = generateOrchestrationRuntimeState(veryLargeInput);

            var           runtimeState  = new OrchestrationRuntimeState();
            DataConverter dataConverter = new JsonDataConverter();

            // test for very large size runtime state that cannot be saved externally: should throw exception
            try
            {
                Stream rawStreamVeryLarge = await RuntimeStateStreamConverter.OrchestrationRuntimeStateToRawStream(
                    newOrchestrationRuntimeStateLarge,
                    runtimeState,
                    dataConverter,
                    true,
                    this.serviceBusSessionSettings,
                    this.azureStorageBlobStore,
                    SessionId);

                Utils.UnusedParameter(rawStreamVeryLarge);
                Assert.Fail("ArgumentException must be thrown");
            }
            catch (OrchestrationException e)
            {
                // expected
                Assert.IsTrue(e.Message.Contains("exceeded"), "Exception must contain exceeded.");
            }
        }
Ejemplo n.º 2
0
        public async Task ConverterCompatibilityTest()
        {
            var smallInput = "abc";
            OrchestrationRuntimeState newOrchestrationRuntimeStateSmall = generateOrchestrationRuntimeState(smallInput);

            DataConverter dataConverter = new JsonDataConverter();

            // deserialize a OrchestrationRuntimeState object, with both compression and not compression
            Stream stream = serializeToStream(dataConverter, newOrchestrationRuntimeStateSmall, true);
            OrchestrationRuntimeState convertedRuntimeStateSmall = await RuntimeStateStreamConverter.RawStreamToRuntimeState(stream, "sessionId", null, dataConverter);

            verifyEventInput(smallInput, convertedRuntimeStateSmall);

            stream = serializeToStream(dataConverter, newOrchestrationRuntimeStateSmall, false);
            convertedRuntimeStateSmall = await RuntimeStateStreamConverter.RawStreamToRuntimeState(stream, "sessionId", null, dataConverter);

            verifyEventInput(smallInput, convertedRuntimeStateSmall);

            // deserialize a IList<HistoryEvent> object, with both compression and not compression
            Stream stream2 = serializeToStream(dataConverter, newOrchestrationRuntimeStateSmall.Events, true);
            OrchestrationRuntimeState convertedRuntimeStateSmall2 = await RuntimeStateStreamConverter.RawStreamToRuntimeState(stream2, "sessionId", null, dataConverter);

            verifyEventInput(smallInput, convertedRuntimeStateSmall2);

            stream2 = serializeToStream(dataConverter, newOrchestrationRuntimeStateSmall.Events, false);
            convertedRuntimeStateSmall2 = await RuntimeStateStreamConverter.RawStreamToRuntimeState(stream2, "sessionId", null, dataConverter);

            verifyEventInput(smallInput, convertedRuntimeStateSmall2);
        }
Ejemplo n.º 3
0
        public async Task LargeRuntimeStateConverterTest()
        {
            string largeInput = TestUtils.GenerateRandomString(5 * 1024);
            OrchestrationRuntimeState newOrchestrationRuntimeStateLarge = generateOrchestrationRuntimeState(largeInput);

            var           runtimeState  = new OrchestrationRuntimeState();
            DataConverter dataConverter = new JsonDataConverter();

            // a large runtime state that needs external storage.
            Stream rawStreamLarge = await RuntimeStateStreamConverter.OrchestrationRuntimeStateToRawStream(
                newOrchestrationRuntimeStateLarge,
                runtimeState,
                dataConverter,
                true,
                this.serviceBusSessionSettings,
                this.azureStorageBlobStore,
                SessionId);

            OrchestrationRuntimeState convertedRuntimeStateLarge = await RuntimeStateStreamConverter.RawStreamToRuntimeState(rawStreamLarge, "sessionId", this.azureStorageBlobStore, dataConverter);

            verifyEventInput(largeInput, convertedRuntimeStateLarge);

            // test for un-compress case
            string largeInput2 = TestUtils.GenerateRandomString(3 * 1024);
            OrchestrationRuntimeState newOrchestrationRuntimeStateLarge2 = generateOrchestrationRuntimeState(largeInput2);
            Stream rawStreamLarge2 = await RuntimeStateStreamConverter.OrchestrationRuntimeStateToRawStream(
                newOrchestrationRuntimeStateLarge2,
                runtimeState,
                dataConverter,
                false,
                this.serviceBusSessionSettings,
                this.azureStorageBlobStore,
                SessionId);

            OrchestrationRuntimeState convertedRuntimeStateLarge2 = await RuntimeStateStreamConverter.RawStreamToRuntimeState(rawStreamLarge2, "sessionId", this.azureStorageBlobStore, dataConverter);

            verifyEventInput(largeInput2, convertedRuntimeStateLarge2);

            // test for an un-implemented (or null) IBlobStorage for large runtime states: should throw exception
            try
            {
                await
                RuntimeStateStreamConverter.OrchestrationRuntimeStateToRawStream(
                    newOrchestrationRuntimeStateLarge,
                    runtimeState,
                    dataConverter,
                    true,
                    this.serviceBusSessionSettings,
                    null,
                    SessionId);

                Assert.Fail("ArgumentException must be thrown");
            }
            catch (OrchestrationException e)
            {
                // expected
                Assert.IsTrue(e.Message.Contains("IOrchestrationServiceBlobStore"), "Exception must contain IOrchestrationServiceBlobStore.");
            }
        }
Ejemplo n.º 4
0
        public async Task SmallRuntimeStateConverterTest()
        {
            var smallInput = "abc";

            OrchestrationRuntimeState newOrchestrationRuntimeStateSmall = generateOrchestrationRuntimeState(smallInput);

            var           runtimeState  = new OrchestrationRuntimeState();
            DataConverter dataConverter = new JsonDataConverter();

            // a small runtime state doesn't need external storage.
            Stream rawStreamSmall = await RuntimeStateStreamConverter.OrchestrationRuntimeStateToRawStream(
                newOrchestrationRuntimeStateSmall,
                runtimeState,
                dataConverter,
                true,
                this.serviceBusSessionSettings,
                this.azureStorageBlobStore,
                SessionId);

            OrchestrationRuntimeState convertedRuntimeStateSmall = await RuntimeStateStreamConverter.RawStreamToRuntimeState(rawStreamSmall, "sessionId", this.azureStorageBlobStore, dataConverter);

            verifyEventInput(smallInput, convertedRuntimeStateSmall);

            // test for un-compress case
            Stream rawStreamSmall2 = await RuntimeStateStreamConverter.OrchestrationRuntimeStateToRawStream(
                newOrchestrationRuntimeStateSmall,
                runtimeState,
                dataConverter,
                false,
                this.serviceBusSessionSettings,
                this.azureStorageBlobStore,
                SessionId);

            OrchestrationRuntimeState convertedRuntimeStateSmall2 = await RuntimeStateStreamConverter.RawStreamToRuntimeState(rawStreamSmall2, "sessionId", this.azureStorageBlobStore, dataConverter);

            verifyEventInput(smallInput, convertedRuntimeStateSmall2);

            // test for backward comp: ok for an un-implemented (or null) IBlobStorage for small runtime states
            Stream rawStreamSmall3 = await RuntimeStateStreamConverter.OrchestrationRuntimeStateToRawStream(
                newOrchestrationRuntimeStateSmall,
                runtimeState,
                dataConverter,
                true,
                this.serviceBusSessionSettings,
                null,
                SessionId);

            OrchestrationRuntimeState convertedRuntimeStateSmall3 = await RuntimeStateStreamConverter.RawStreamToRuntimeState(rawStreamSmall3, "sessionId", null, dataConverter);

            verifyEventInput(smallInput, convertedRuntimeStateSmall3);
        }