Ejemplo n.º 1
0
        public async Task TestSymsSavingAndFetchingDocument()
        {
            SymsTestHelper.CheckSymsEnvironment();
            var symsAdapter = SymsTestHelper.CreateAdapterWithClientId();
            await SymsTestHelper.CleanDatabase(symsAdapter, SymsTestHelper.DatabaseName);

            var testInputPath     = TestHelper.GetInputFolderPath(testsSubpath, nameof(TestSymsSavingAndFetchingDocument));
            var testActOutputPath = TestHelper.GetActualOutputFolderPath(testsSubpath, nameof(TestSymsSavingAndFetchingDocument));
            var testExpOutputPath = TestHelper.GetExpectedOutputFolderPath(testsSubpath, nameof(TestSymsSavingAndFetchingDocument));

            CdmCorpusDefinition corpus = new CdmCorpusDefinition();

            corpus.SetEventCallback(new EventCallback {
                Invoke = CommonDataModelLoader.ConsoleStatusReport
            }, CdmStatusLevel.Warning);

            var adlsAdapter1 = SymsTestHelper.CreateADLSAdapterWithClientIdWithSharedKey(1);
            var adlsAdapter2 = SymsTestHelper.CreateADLSAdapterWithClientIdWithSharedKey(2);

            var localInputAdapter     = new LocalAdapter(testInputPath);
            var localActOutputAdapter = new LocalAdapter(testActOutputPath);
            var localExpOutputAdapter = new LocalAdapter(testExpOutputPath);

            corpus.Storage.Mount("adls1", adlsAdapter1);
            corpus.Storage.Mount("adls2", adlsAdapter2);
            corpus.Storage.Mount("syms", symsAdapter);
            corpus.Storage.Mount("localInput", localInputAdapter);
            corpus.Storage.Mount("localActOutput", localActOutputAdapter);
            corpus.Storage.Mount("localExpOutput", localExpOutputAdapter);

            corpus.Storage.Unmount("cdm");
            corpus.Storage.DefaultNamespace = "localInput";

            var manifest = await corpus.FetchObjectAsync <CdmManifestDefinition>("default.manifest.cdm.json");

            manifest.ManifestName = SymsTestHelper.DatabaseName;
            await TestSymsSaveManifest(manifest);
            await TestSymsFetchManifest(corpus, manifest, "default.manifest.cdm.json");
            await TestSymsFetchDocument(corpus, manifest);

            var manifestModified = await corpus.FetchObjectAsync <CdmManifestDefinition>("defaultmodified.manifest.cdm.json");

            manifestModified.ManifestName = SymsTestHelper.DatabaseName;
            manifestModified.Entities[0].LastFileModifiedTime = DateTimeOffset.UtcNow;
            await TestSymsSaveManifest(manifestModified);
            await TestSymsFetchManifest(corpus, manifestModified, "defaultmodified.manifest.cdm.json");
            await TestSymsFetchDocument(corpus, manifestModified);

            var tasks = new List <Func <Task> >
            {
                TestSymsSmartADLSAdapterMountLogic,
                TestSymsSmartADLSAdapterMountLogic,
                TestSymsSmartADLSAdapterMountLogic,
                TestSymsSmartADLSAdapterMountLogic
            };
            await Task.WhenAll(tasks.AsParallel().Select(async task => await task()));

            await SymsTestHelper.CleanDatabase(symsAdapter, SymsTestHelper.DatabaseName);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Test automatic mounting of adls adapter in syms if does not exist.
        /// </summary>
        internal async Task TestSymsSmartADLSAdapterMountLogic()
        {
            var symsAdapter = SymsTestHelper.CreateAdapterWithClientId();
            var corpus      = new CdmCorpusDefinition();

            corpus.SetEventCallback(new EventCallback {
                Invoke = CommonDataModelLoader.ConsoleStatusReport
            }, CdmStatusLevel.Warning);
            corpus.Storage.Mount("syms", symsAdapter);

            var adlsAdapter1 = SymsTestHelper.CreateADLSAdapterWithClientIdWithSharedKey(1);
            var adlsAdapter2 = SymsTestHelper.CreateADLSAdapterWithClientIdWithSharedKey(2);

            int countAdapterCountBefore = corpus.Storage.NamespaceAdapters.Count;
            var manifestReadDatabases   = await corpus.FetchObjectAsync <CdmManifestDefinition>($"syms:/databases.manifest.cdm.json");

            var manifest = await corpus.FetchObjectAsync <CdmManifestDefinition>($"syms:/{manifestReadDatabases.SubManifests[0].ManifestName}/{manifestReadDatabases.SubManifests[0].ManifestName}.manifest.cdm.json", manifestReadDatabases, null, true);

            int countAdapterCountAfter = corpus.Storage.NamespaceAdapters.Count;

            Assert.AreEqual(countAdapterCountBefore + 2, countAdapterCountAfter);
            Assert.IsNotNull(corpus.Storage.AdapterPathToCorpusPath($"https://{adlsAdapter1.Hostname}{adlsAdapter1.Root}"));
            Assert.IsNotNull(corpus.Storage.AdapterPathToCorpusPath($"https://{adlsAdapter2.Hostname}{adlsAdapter2.Root}"));
        }