Example #1
0
        public static AstoriaWebDataService CreateAstoriaDataWebService(Workspace workspace, string webDataServicePrefixName, AstoriaDatabase database, bool skipDataServiceVerify)
        {
            AstoriaWebDataService service = null;

            //Base the creation on the AstoriaTestProperties
            switch (AstoriaTestProperties.Host)
            {
            case Host.WebServiceHost:
            case Host.IDSH:
            case Host.IDSH2:
                service = new AstoriaServiceHost(workspace, webDataServicePrefixName, Environment.MachineName, database);
                break;

            case Host.WebServiceHostRemote:
                service = new AstoriaServiceHost(workspace, webDataServicePrefixName, GetMachineName(), database);
                break;

            default:
                service = new IISWebDataService(workspace, webDataServicePrefixName, GetMachineName(), database);
                break;
            }

            // write out helpful debugging URIs
            if (AstoriaTestProperties.Client == ClientEnum.SILVERLIGHT)
            {
                WriteUriToList(service.ServiceRootUri + "Monitor.aspx");
                WriteUriToList(service.ServiceRootUri + "SilverlightAstoriaTestPage.html");
                WriteUriToList(service.ServiceUri);
            }

            // if running locally in partial trust, ensure that the trusted methods are available
            if (AstoriaTestProperties.IsLocalHost &&
                AstoriaTestProperties.ServiceTrustLevel != TrustLevel.Full &&
                AstoriaTestProperties.RuntimeEnvironment == TestRuntimeEnvironment.Lab)
            {
                Assembly trustedAssembly = typeof(FullTrust.TrustedMethods).Assembly;
                //if (!trustedAssembly.GlobalAssemblyCache)
                //{
                //    AstoriaTestLog.FailAndThrow("Assembly containing fully trusted components must be in the GAC. " +
                //        "Run 'gacutil -if <dll>' on AstoriaTestFramework.FullTrust from a visual studio command prompt");
                //}

                if (!trustedAssembly.IsFullyTrusted)
                {
                    AstoriaTestLog.FailAndThrow("Assembly containing components requiring full trust is not trusted");
                }
            }

            try
            {
                // push the verification step down to the derived classes so that a failure there can be handled accordingly
                //
                service.CreateWebService(!skipDataServiceVerify);
            }
            catch (Exception e)
            {
                // we need to make sure that we don't 'leak' services that fail to start, as it can mean a process is left running that will
                // cause subsequent ArtClean's to fail. This has caused build failures at least once.
                //
                if (AstoriaTestProperties.IsLabRun || AstoriaTestProperties.RuntimeEnvironment == TestRuntimeEnvironment.CheckinSuites)
                {
                    service.Dispose();
                }
                throw new TestFailedException("Failed to create web service", null, null, e);
            }

            if (skipDataServiceVerify)
            {
                // for call logging, we need the directory to exist, and the service doesn't necessarily have permission to create it
                // TODO: find some better, common place to put this for IIS, WebServiceHost, etc. Right now this is the best spot
#if !ClientSKUFramework
                IOUtil.EnsureEmptyDirectoryExists(Path.Combine(service.DestinationFolder, CallOrder.APICallLog.DirectoryName));
#endif

                Thread.Sleep(5000);     //To allow time for the service to start running before requests get made
            }

            return(service);
        }
        public static AstoriaWebDataService CreateAstoriaDataWebService(Workspace workspace, string webDataServicePrefixName, AstoriaDatabase database, bool skipDataServiceVerify)
        {
            AstoriaWebDataService service = null;
            //Base the creation on the AstoriaTestProperties
            switch (AstoriaTestProperties.Host)
            {
                case Host.WebServiceHost:
                case Host.IDSH:
                case Host.IDSH2:
                    service = new AstoriaServiceHost(workspace, webDataServicePrefixName, Environment.MachineName, database);
                    break;

                case Host.WebServiceHostRemote:
                    service = new AstoriaServiceHost(workspace, webDataServicePrefixName, GetMachineName(), database);
                    break;

                default:
                    service = new IISWebDataService(workspace, webDataServicePrefixName, GetMachineName(), database);
                    break;
            }

            // write out helpful debugging URIs
            if (AstoriaTestProperties.Client == ClientEnum.SILVERLIGHT)
            {
                WriteUriToList(service.ServiceRootUri + "Monitor.aspx");
                WriteUriToList(service.ServiceRootUri + "SilverlightAstoriaTestPage.html");
                WriteUriToList(service.ServiceUri);
            }

            // if running locally in partial trust, ensure that the trusted methods are available
            if (AstoriaTestProperties.IsLocalHost
                && AstoriaTestProperties.ServiceTrustLevel != TrustLevel.Full
                && AstoriaTestProperties.RuntimeEnvironment == TestRuntimeEnvironment.Lab)
            {
                Assembly trustedAssembly = typeof(FullTrust.TrustedMethods).Assembly;
                //if (!trustedAssembly.GlobalAssemblyCache)
                //{
                //    AstoriaTestLog.FailAndThrow("Assembly containing fully trusted components must be in the GAC. " + 
                //        "Run 'gacutil -if <dll>' on AstoriaTestFramework.FullTrust from a visual studio command prompt");
                //}

                if (!trustedAssembly.IsFullyTrusted)
                {
                    AstoriaTestLog.FailAndThrow("Assembly containing components requiring full trust is not trusted");
                }
            }

            try
            {
                // push the verification step down to the derived classes so that a failure there can be handled accordingly
                //
                service.CreateWebService(!skipDataServiceVerify);
            }
            catch (Exception e)
            {
                // we need to make sure that we don't 'leak' services that fail to start, as it can mean a process is left running that will
                // cause subsequent ArtClean's to fail. This has caused build failures at least once.
                //
                if (AstoriaTestProperties.IsLabRun || AstoriaTestProperties.RuntimeEnvironment == TestRuntimeEnvironment.CheckinSuites)
                {
                    service.Dispose();
                }
                throw new TestFailedException("Failed to create web service", null, null, e);
            }

            if (skipDataServiceVerify)
            {
                // for call logging, we need the directory to exist, and the service doesn't necessarily have permission to create it
                // TODO: find some better, common place to put this for IIS, WebServiceHost, etc. Right now this is the best spot
#if !ClientSKUFramework
                IOUtil.EnsureEmptyDirectoryExists(Path.Combine(service.DestinationFolder, CallOrder.APICallLog.DirectoryName));
#endif

                Thread.Sleep(5000);     //To allow time for the service to start running before requests get made
            }

            return service;
        }