示例#1
0
        public static string GenerateEndpoint(
            HTTPClient.ClusterEnvironment clusterEnv,
            string gatewayAddress,
            string fqdn,
            bool isPrimary)
        {
            string replica = isPrimary ? "PrimaryReplica" : "RandomSecondaryReplica";

            if (clusterEnv == HTTPClient.ClusterEnvironment.Windows)
            {
                return(string.Format("http://{0}/{1}?TargetReplicaSelector={2}", gatewayAddress, fqdn, replica));
            }
            else
            {
                return(string.Format("http://{0}?{1}&TargetReplicaSelector={2}", gatewayAddress.Split(':')[0] + ":8505", "ServiceInstanceName=" + fqdn, replica));
            }
        }
示例#2
0
        public static string GenerateEndpoint(
            HTTPClient.ClusterEnvironment clusterEnv,
            string gatewayAddress,
            string fqdn,
            string partitionKey,
            string partitionKind,
            bool isPrimary)
        {
            string sufix = string.Format("PartitionKey={0}&PartitionKind={1}&TargetReplicaSelector={2}",
                                         partitionKey, partitionKind, isPrimary ? "PrimaryReplica" : "RandomSecondaryReplica");

            if (clusterEnv == HTTPClient.ClusterEnvironment.Windows)
            {
                return(string.Format("http://{0}/{1}?{2}", gatewayAddress, fqdn, sufix));
            }
            else
            {
                return(string.Format("http://{0}?{1}&{2}", gatewayAddress.Split(':')[0] + ":8505", "ServiceInstanceName=" + fqdn, sufix));
            }
        }
示例#3
0
        /// <summary>
        /// The Main of the client.
        /// </summary>
        /// <param name="args">Arguments to the program.</param>
        public async Task <Dictionary <string, string> > MainWorkload(
            string TaskId,
            string ServiceName,
            string[] GatewayAddresses,
            string[] HttpGatewayAddresses,
            Uri RouterAddress,
            SecurityCredentials credentials,
            WorkloadIdentifier WorkloadId,
            Dictionary <string, string> Parameters,
            ServicePartitionType PartitionType,
            string NamedPartitionKey,
            long Int64PartitionKey,
            TimeSpan SendTimeout,
            bool RetryCall,
            int RetryCount,
            bool isDemo,
            bool useTestability,
            int loopCount,
            bool RunForever,
            bool isPAAS,
            HTTPClient.ClusterEnvironment clusterEnvironment,
            CancellationToken cancellationToken
            )
        {
            Dictionary <string, string> results = new Dictionary <string, string>();

            ScriptTestTaskId = TaskId;

            gatewayAddresses  = GatewayAddresses;
            namedPartitionKey = NamedPartitionKey;
            int64PartitionKey = Int64PartitionKey;
            sendTimeout       = SendTimeout;
            retryCount        = RetryCount;

            BasicWorkTest basicWorkTest;

            Uri serviceName = new Uri(ServiceName);

            // Run Basic Workload test.
            switch (PartitionType)
            {
            case ServicePartitionType.Singleton:
                Tracing.TraceEvent(TraceEventType.Information, 0, "Creating Test Manager: Singleton Service Name: {0}", serviceName.ToString());

                basicWorkTest = new BasicWorkTest(
                    serviceName,
                    gatewayAddresses,
                    HttpGatewayAddresses,
                    RouterAddress,
                    credentials,
                    sendTimeout,
                    retryCount,
                    isDemo,
                    useTestability,
                    isPAAS,
                    clusterEnvironment,
                    RetryCall);
                break;

            case ServicePartitionType.Uniform:
                Tracing.TraceEvent(
                    TraceEventType.Information,
                    0,
                    "Creating Test Manager: Service Name: {0}, partition key: {1}.",
                    serviceName.ToString(),
                    int64PartitionKey);

                basicWorkTest = new BasicWorkTest(
                    serviceName,
                    int64PartitionKey,
                    gatewayAddresses,
                    HttpGatewayAddresses,
                    RouterAddress,
                    credentials,
                    sendTimeout,
                    retryCount,
                    isDemo,
                    useTestability,
                    isPAAS,
                    clusterEnvironment,
                    RetryCall);
                break;

            case ServicePartitionType.Named:
                Tracing.TraceEvent(
                    TraceEventType.Information,
                    0,
                    "Creating Test Manager: Service Name: {0}, partition key: {1}.",
                    serviceName.ToString(),
                    namedPartitionKey);

                basicWorkTest = new BasicWorkTest(
                    serviceName,
                    namedPartitionKey,
                    gatewayAddresses,
                    HttpGatewayAddresses,
                    RouterAddress,
                    credentials,
                    sendTimeout,
                    retryCount,
                    isDemo,
                    useTestability,
                    isPAAS,
                    clusterEnvironment,
                    RetryCall);
                break;

            default:
                Tracing.TraceEvent(
                    TraceEventType.Critical,
                    0,
                    "Main: Unexpected type {0} when creating the test manager.",
                    PartitionType);

                Console.Error.WriteLine("MCF.Client.MainWorkload: Internal Error: Unexpected type {0} wehen creating the test manager.",
                                        PartitionType);
                return(results);
            }

            await basicWorkTest.InitializeAsync();

            if (WorkloadId == WorkloadIdentifier.LegacyWorkload)
            {
                //
                // Workload 0 is special in that it runs the workload and failover tests
                // cases as the legacy ServiceTestClient did
                //
                await basicWorkTest.RunAsync(loopCount, cancellationToken, Parameters);
            }
            else if (WorkloadId == WorkloadIdentifier.LegacyTransientFaultWorkload)
            {
                await basicWorkTest.RunTransientFaultWorkloadAsync(loopCount, cancellationToken);
            }
            else
            {
                //
                // Other workloads are dependent upon how the service implements them
                //
                results = await basicWorkTest.RunSpecificWorkloadAsync(WorkloadId, RunForever, Parameters, sendTimeout, RetryCall, cancellationToken);
            }

            return(results);
        }