public bool StartProcess(KontrolSystemProcess process, Vessel vessel) { switch (process.State) { case KontrolSystemProcessState.Available: KSPContext context = new KSPContext(consoleBuffer); Entrypoint entrypoint = process.EntrypointFor(HighLogic.LoadedScene, context); if (entrypoint == null) { return(false); } CorouttineAdapter adapter = new CorouttineAdapter(entrypoint(vessel), context, message => OnProcessDone(process, message)); process.MarkRunning(context); Coroutine coroutine = StartCoroutine(adapter); if (coroutines.ContainsKey(process.id)) { StopCoroutine(coroutines[process.id]); coroutines[process.id] = coroutine; } else { coroutines.Add(process.id, coroutine); } return(true); default: return(false); } }
public async Task TestEntrypointCsvElasticsearch() { // ARRANGE TestLambdaLogger testLogger = new TestLambdaLogger(); TestClientContext clientContext = new TestClientContext(); TestLambdaContext context = new TestLambdaContext() { FunctionName = "PriceListApiFormatter", FunctionVersion = "1", Logger = testLogger, ClientContext = clientContext }; ServiceRequest serviceRequest = new ServiceRequest("AmazonES"); Mock <IAmazonS3> s3 = new Mock <IAmazonS3>(); Mock <IAmazonLambda> lambda = new Mock <IAmazonLambda>(); Mock <IAmazonSimpleNotificationService> sns = new Mock <IAmazonSimpleNotificationService>(); s3.Setup(x => x.PutObjectAsync(It.IsAny <PutObjectRequest>(), default(CancellationToken))).Returns(Task.FromResult(new PutObjectResponse())); Entrypoint entry = new Entrypoint(sns.Object, s3.Object, lambda.Object); // ACT await entry.RunForServiceAsync(serviceRequest, context); // ASSERT }
public async Task TestDistributor() { // ARRANGE TestLambdaLogger testLogger = new TestLambdaLogger(); TestClientContext clientContext = new TestClientContext(); TestLambdaContext context = new TestLambdaContext() { FunctionName = "PriceListApiFormatter", FunctionVersion = "1", Logger = testLogger, ClientContext = clientContext }; SNSEvent ev = new SNSEvent(); Mock <IAmazonS3> s3 = new Mock <IAmazonS3>(); Mock <IAmazonLambda> lambda = new Mock <IAmazonLambda>(); Mock <IAmazonSimpleNotificationService> sns = new Mock <IAmazonSimpleNotificationService>(); lambda.Setup(x => x.InvokeAsync(It.IsAny <InvokeRequest>(), default(CancellationToken))).Returns(Task.FromResult(new InvokeResponse())); Entrypoint entry = new Entrypoint(sns.Object, s3.Object, lambda.Object); // ACT await entry.LaunchWorkersAsync(ev, context); // ASSERT }
public async Task TestEntrypointJsonRedshift() { // ARRANGE System.Environment.SetEnvironmentVariable("PRICELIST_FORMAT", "json"); System.Environment.SetEnvironmentVariable("BUCKET", "mybucket"); TestLambdaLogger testLogger = new TestLambdaLogger(); TestClientContext clientContext = new TestClientContext(); TestLambdaContext context = new TestLambdaContext() { FunctionName = "PriceListApiFormatter", FunctionVersion = "1", Logger = testLogger, ClientContext = clientContext }; ServiceRequest serviceRequest = new ServiceRequest("AmazonRedshift"); Mock <IAmazonS3> s3 = new Mock <IAmazonS3>(); Mock <IAmazonLambda> lambda = new Mock <IAmazonLambda>(); Mock <IAmazonSimpleNotificationService> sns = new Mock <IAmazonSimpleNotificationService>(); s3.Setup(x => x.PutObjectAsync(It.IsAny <PutObjectRequest>(), default(CancellationToken))).Returns(Task.FromResult(new PutObjectResponse())); Entrypoint entry = new Entrypoint(sns.Object, s3.Object, lambda.Object); // ACT await entry.RunForServiceAsync(serviceRequest, context); // ASSERT }
public async Task Live_TestGetDataWithFilterAsync() { // ARRANGE Entrypoint ep = new Entrypoint(); APIGatewayProxyRequest request = new APIGatewayProxyRequest() { QueryStringParameters = new Dictionary <string, string>() { { "output", "None" }, { "services", "ec2,autoscaling,awswaf" } } }; TestLambdaLogger logger = new TestLambdaLogger(); TestLambdaContext context = new TestLambdaContext(); context.Logger = logger; // ACT APIGatewayProxyResponse response = await ep.GetData(request, context); // ASSERT Assert.Equal(200, response.StatusCode); Assert.True(!String.IsNullOrEmpty(response.Body)); }
public async Task TestRetry() { // ARRANGE Entrypoint Entry = new Entrypoint(); TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); ILambdaContext Context = new TestLambdaContext() { FunctionName = "Common", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext }; Environment.SetEnvironmentVariable("MARKER_BUCKET", MARKER_BUCKET); Environment.SetEnvironmentVariable("MARKER_KEY", MARKER_KEY); Environment.SetEnvironmentVariable("RESULT_BUCKET", RESULT_BUCKET); Environment.SetEnvironmentVariable("RETRY_BUCKET", RETRY_BUCKET); Environment.SetEnvironmentVariable("RETRY_KEY", RETRY_KEY); // ACT await Entry.RetryAsync(Event, Context); // ASSERT }
private async Task TestCURDelete(string reportName) { // ARRANGE string Json = GenerateDeleteJson(reportName); CustomResourceRequest Request = JsonConvert.DeserializeObject <CustomResourceRequest>(Json); TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); SharedCredentialsFile Creds = new SharedCredentialsFile(); Creds.TryGetProfile($"{Environment.UserName}-dev", out CredentialProfile Profile); ImmutableCredentials Cr = Profile.GetAWSCredentials(Creds).GetCredentials(); TestLambdaContext Context = new TestLambdaContext() { FunctionName = "CostAndUsageReportResource", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext, InvokedFunctionArn = "arn:aws:lambda:us-east-1:123456789012:function:FunctionName" }; // ACT Entrypoint Ep = new Entrypoint(); await Ep.Execute(Request, Context); // ASSERT }
public override int GetHashCode() { int hash = 1; if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (Entrypoint.Length != 0) { hash ^= Entrypoint.GetHashCode(); } if (resources_ != null) { hash ^= Resources.GetHashCode(); } if (triggers_ != null) { hash ^= Triggers.GetHashCode(); } if (pubsub_ != null) { hash ^= Pubsub.GetHashCode(); } hash ^= files_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
protected virtual CreateContainerParameters GetCreateContainerParameters(string[] environmentVariables) { var createParams = new CreateContainerParameters { Name = Name, Image = $"{ImageName}:{Tag}", AttachStdout = true, Env = environmentVariables, Hostname = Name, HostConfig = new HostConfig { PublishAllPorts = Ports == null } }; if (Ports != null) { createParams.HostConfig.PortBindings = Ports .ToDictionary( p => $"{p.Key}/tcp", p => (IList <PortBinding>) new List <PortBinding> { new PortBinding { HostPort = p.Value.ToString() } }); } if (Entrypoint != null && Entrypoint.Any()) { createParams.Entrypoint = Entrypoint; } return(createParams); }
public void Destroy() { if (SamplerHandle.HasValue) { Entrypoint.ReleaseHandle(SamplerHandle.Value); SamplerHandle = null; } }
private void _read() { _header = new Header(m_io, this, m_root); _entrypoint = new Entrypoint(m_io, this, m_root); _routineConvention = new RoutineConvention(m_io, this, m_root); _subroutineConvention = new SubroutineConvention(m_io, this, m_root); _specSubroutineConventions = new SpecSubroutineConventions(m_io, this, m_root); _exploredBlocks = new ExploredBlocks(m_io, this, m_root); }
public override int GetHashCode() { unchecked { var hashCode = (Namespace != null ? Namespace.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Entrypoint != null ? Entrypoint.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Instance != null ? Instance.GetHashCode() : 0); return(hashCode); } }
private static int Main(string[] args) { Console.Title = "EazFixer - Squirrel"; try { Entrypoint.Start(args); } catch (Exception ex) { Error(ex.Message); } Console.ResetColor(); return(0); }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (Entrypoint.metaState == MetaState.Paused) { Entrypoint.SetMetaState(MetaState.Gameplay); } else if (Entrypoint.metaState == MetaState.Gameplay) { Entrypoint.SetMetaState(MetaState.Paused); } } }
/// <summary> /// Execute the framework with execution parameters /// </summary> public FrameworkExecutionResult Execute(string executionParameters) { PrepareTypes(); // set exception serialization Entrypoint.SerializeExceptions = serializeExceptions; // execute the framework string result = Entrypoint.Start( executionParameters, types.ToArray() ); return(new FrameworkExecutionResult(result)); }
public async Task Live_TestManualLoadFromSHD() { // ARRANGE Entrypoint ep = new Entrypoint(); APIGatewayProxyRequest request = new APIGatewayProxyRequest(); TestLambdaLogger logger = new TestLambdaLogger(); TestLambdaContext context = new TestLambdaContext(); context.Logger = logger; // ACT await ep.ManualLoadDataFromSource(request, context); // ASSERT Assert.True(true); }
public async Task Live_TestScheduledLoadFromSHD() { // ARRANGE Entrypoint ep = new Entrypoint(); ScheduledEvent request = new ScheduledEvent(); TestLambdaLogger logger = new TestLambdaLogger(); TestLambdaContext context = new TestLambdaContext(); context.Logger = logger; // ACT await ep.ScheduledLoadDataFromSource(request, context); // ASSERT Assert.True(true); }
private async Task TestCURCreateParquet(string reportName) { string Json = GenerateCreateJsonParquet(reportName); CustomResourceRequest Request = JsonConvert.DeserializeObject <CustomResourceRequest>(Json); TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); TestLambdaContext Context = new TestLambdaContext() { FunctionName = "CostAndUsageReportResource", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext, InvokedFunctionArn = "arn:aws:lambda:us-east-1:123456789012:function:FunctionName" }; // ACT Entrypoint Ep = new Entrypoint(); await Ep.Execute(Request, Context); }
public async Task Live_TestGetDataAsync() { // ARRANGE Entrypoint ep = new Entrypoint(); APIGatewayProxyRequest request = new APIGatewayProxyRequest() { QueryStringParameters = new Dictionary <string, string>() { { "output", "None" } } }; TestLambdaLogger logger = new TestLambdaLogger(); TestLambdaContext context = new TestLambdaContext(); context.Logger = logger; // ACT APIGatewayProxyResponse response = await ep.GetData(request, context); // ASSERT Assert.Equal(200, response.StatusCode); }
public async Task TestCreate() { // ARRANGE AWSConfigs.AWSProfilesLocation = $"{Environment.GetEnvironmentVariable("UserProfile")}\\.aws\\credentials"; string StreamName = "test-stream"; string PresignedUrlBucket = "pre-sign-url-bucket"; string AccountNumber = "123456789012"; string Region = "us-east-1"; IAmazonS3 S3Client = new AmazonS3Client(); GetPreSignedUrlRequest Req = new GetPreSignedUrlRequest() { BucketName = PresignedUrlBucket, Key = "result.txt", Expires = DateTime.Now.AddMinutes(2), Protocol = Protocol.HTTPS, Verb = HttpVerb.PUT }; string PreSignedUrl = S3Client.GetPreSignedURL(Req); string Json = $@" {{ ""requestType"":""create"", ""responseUrl"":""{PreSignedUrl}"", ""stackId"":""arn:aws:cloudformation:{Region}:{AccountNumber}:stack/stack-name/{Guid.NewGuid().ToString()}"", ""requestId"":""12345678"", ""resourceType"":""Custom::KinesisStreamAwaiter"", ""logicalResourceId"":""KinesisStreamAwaiter"", ""resourceProperties"":{{ ""StreamName"":""{StreamName}"" }} }}"; CustomResourceRequest Request = JsonConvert.DeserializeObject <CustomResourceRequest>(Json); TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); TestLambdaContext Context = new TestLambdaContext() { FunctionName = "KinesisStreamAwaiter", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext, LogGroupName = "aws/lambda/KinesisStreamAwaiter", LogStreamName = Guid.NewGuid().ToString(), RemainingTime = TimeSpan.FromSeconds(300) }; Entrypoint Entrypoint = new Entrypoint(); // ACT IAmazonKinesis KinesisClient = new AmazonKinesisClient(); CreateStreamRequest CreateReq = new CreateStreamRequest() { ShardCount = 1, StreamName = StreamName }; CreateStreamResponse CreateResponse = await KinesisClient.CreateStreamAsync(CreateReq); try { CustomResourceResult Response = await Entrypoint.ExecuteAsync(Request, Context); // ASSERT Assert.True(Response.IsSuccess); } finally { DeleteStreamRequest DeleteReq = new DeleteStreamRequest() { StreamName = StreamName }; await KinesisClient.DeleteStreamAsync(DeleteReq); } }
public void Push(Car car) { Entrypoint.Push(car); }
static void Main(string[] args) { Entrypoint.MainEntrypoint(args, typeof(FrameworkAbstraction)); }
public void ResumeGame() { Entrypoint.SetMetaState(MetaState.Gameplay); }
private async Task TestManifestFile() { // ARRANGE string Json = $@" {{ ""Records"": [ {{ ""eventVersion"": ""2.0"", ""eventSource"": ""aws:s3"", ""awsRegion"": ""{Region}"", ""eventTime"": ""2018-10-01T01:00:00.000Z"", ""eventName"": ""ObjectCreated:Put"", ""userIdentity"": {{ ""principalId"": ""EXAMPLE"" }}, ""requestParameters"": {{ ""sourceIPAddress"": ""127.0.0.1"" }}, ""responseElements"": {{ ""x-amz-request-id"": ""EXAMPLE123456789"", ""x-amz-id-2"": ""EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH"" }}, ""s3"": {{ ""s3SchemaVersion"": ""1.0"", ""configurationId"": ""testConfigRule"", ""bucket"": {{ ""name"": ""{SourceBucket}"", ""ownerIdentity"": {{ ""principalId"": ""EXAMPLE"" }}, ""arn"": ""arn:{AWSPartition}:s3:::{SourceBucket}"" }}, ""object"": {{ ""key"": ""{SourceManifestKey}"", ""size"": 7658, ""eTag"": ""0409fb62239b5d5daa27a2a1982c4dc2"", ""sequencer"": ""0A1B2C3D4E5F678901"" }} }} }} ] }} "; TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); TestLambdaContext Context = new TestLambdaContext() { FunctionName = "CURManager", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext, LogGroupName = "aws/lambda/CURManager", LogStreamName = Guid.NewGuid().ToString(), RemainingTime = TimeSpan.FromSeconds(300), InvokedFunctionArn = $"arn:{AWSPartition}:lambda:{Region}:{AccountNumber}:function:CURManager" }; S3Event Event = JsonConvert.DeserializeObject <S3Event>(Json); Environment.SetEnvironmentVariable("DESTINATION_S3_BUCKET", DestinationBucket); Entrypoint Entry = new Entrypoint(); // ACT await Entry.Exec(Event, Context); // ASSERT // No exception }
public void RestartGame() { Entrypoint.SetMetaState(MetaState.StartMenu); }
public void SurviveGame() { Entrypoint.SetMetaState(MetaState.Gameplay); }
public void SurviveAgain() { Entrypoint.SetMetaState(MetaState.StartMenu); }
private void UpdateImageConfig(ImageV1 image) { var config = image.config; var historyStrings = new List <string>(); // do git labels before other labels, to enable users to overwrite them if (GitLabels.HasValue()) { IDictionary <string, string> gitLabels = null; try { gitLabels = Utils.GitLabels.GetLabels(GitLabels.Value(), GitLabelsPrefix.Value()); } catch (Exception ex) { _logger.LogWarning($"Failed to read git labels: {ex.Message}"); } if (gitLabels != null) { foreach (var l in gitLabels) { config.Labels = config.Labels ?? new Dictionary <string, string>(); config.Labels[l.Key] = l.Value; historyStrings.Add($"--gitLabels {l.Key}={l.Value}"); } } } foreach (var label in Label.Values) { config.Labels = config.Labels ?? new Dictionary <string, string>(); var split = label.Split('=', 2); if (split.Length != 2) { throw new Exception($"Invalid label {label}"); } config.Labels[split[0]] = split[1]; historyStrings.Add($"--label {split[0]}={split[1]}"); } foreach (var var in Env.Values) { config.Env = config.Env ?? new List <string>(); config.Env.Add(var); historyStrings.Add($"--env {var}"); } if (WorkDir.HasValue()) { config.WorkingDir = WorkDir.Value(); historyStrings.Add($"--workdir {WorkDir.Value()}"); } if (User.HasValue()) { config.User = User.Value(); historyStrings.Add($"--user {User.Value()}"); } if (Cmd.HasValue()) { config.Cmd = SplitCmd(Cmd.Value()).ToList(); var cmdString = string.Join(", ", config.Cmd.Select(c => $"\"{c}\"")); historyStrings.Add($"--cmd {cmdString}"); } if (Entrypoint.HasValue()) { config.Entrypoint = SplitCmd(Entrypoint.Value()).ToList(); var epString = string.Join(", ", config.Entrypoint.Select(c => $"\"{c}\"")); historyStrings.Add($"--entrypoint {epString}"); } if (historyStrings.Any()) { image.history.Add(ImageV1History.Create(string.Join(", ", historyStrings), true)); } foreach (var h in historyStrings) { _logger.LogDebug(h); } }
public void AddEntryPoint(Entrypoint entryPoint) { entryPoints.Add(entryPoint); }
static void Main(string[] args) { Entrypoint.Start <SandboxApp>("Sandbox"); }