Exemple #1
0
        public void Escapes()
        {
            var f = FunctionId.Build("h-1", "F-:1");

            string str = f.ToString();

            Assert.Equal("h:2D1-f:2D:3A1", str);
        }
Exemple #2
0
        public async Task GetTimelineEmptyInvocations()
        {
            // Look in timeline range where there's no functions invocations.
            // This verifies the time range is getting parsed by the webapi and passed through.
            string uri = _endpoint + "/api/functions/invocations/" + FunctionId.Build(Fixture.HostName, "alpha") +
                         "/timeline?limit=11&start=2005-01-01";
            var response = await _client.GetJsonAsync <TimelineResponseEntry[]>(uri);

            Assert.Equal(0, response.Length);
        }
Exemple #3
0
        public void Operators()
        {
            var f1 = FunctionId.Build("h1", "FFF1");
            var f2 = FunctionId.Build("H1", "fff1"); // different casing.

            Assert.Equal("h1-fff1", f2.ToString());

            // Names have been normalized.
            Assert.True(f1.Equals(f2));
            Assert.Equal(f1.GetHashCode(), f2.GetHashCode());
            Assert.True(f1 == f2);
            Assert.False(f1 != f2);
        }
Exemple #4
0
        public async Task GetInvocations()
        {
            // Lookup functions by name
            string uri      = _endpoint + "/api/functions/definitions/" + FunctionId.Build(Fixture.HostName, "alpha") + "/invocations?limit=11";
            var    response = await _client.GetJsonAsync <DashboardSegment <InvocationLogViewModel> >(uri);

            var item = _fixture.Data[0];

            var x = response.entries.ToArray();

            Assert.Equal(item.FunctionInstanceId.ToString(), x[0].id);
            Assert.Equal("2010-03-06T18:13:20Z", x[0].whenUtc);
            Assert.Equal(120000.0, x[0].duration);
            Assert.Equal("CompletedSuccess", x[0].status);
            Assert.Equal("alpha", x[0].functionDisplayTitle);
        }
Exemple #5
0
        public async Task GetInvocations()
        {
            // Lookup functions by name
            string uri      = _endpoint + "/api/functions/definitions/" + FunctionId.Build(Fixture.HostName, "alpha") + "/invocations?limit=11";
            var    response = await _client.GetJsonAsync <DashboardSegment <InvocationLogViewModel> >(uri);

            Assert.Equal(_fixture.ExpectedItems.Count, response.entries.Length);

            for (int i = 0; i < response.entries.Length; i++)
            {
                var expectedItem = _fixture.ExpectedItems[i];
                var actualItem   = response.entries[i];

                AssertEqual(expectedItem, actualItem);

                Assert.Equal("alpha", actualItem.functionDisplayTitle);
            }
        }
Exemple #6
0
        public async Task GetTimelineInvocations()
        {
            // Lookup functions by name
            string uri = _endpoint + "/api/functions/invocations/" + FunctionId.Build(Fixture.HostName, "alpha") +
                         "/timeline?limit=11&start=2001-01-01";
            var response = await _client.GetJsonAsync <TimelineResponseEntry[]>(uri);

            // This only includes completed / failed functions, not NeverFinished/Running.
            // Important that DateTimes include the 'Z' suffix, meaning UTC timezone.
            Assert.Equal(2, response.Length);
            Assert.Equal("2010-03-06T18:10:00Z", response[0].Start);
            Assert.Equal(1, response[0].TotalFail);
            Assert.Equal(0, response[0].TotalPass);
            Assert.Equal(1, response[0].TotalRun);

            Assert.Equal("2010-03-06T18:11:00Z", response[1].Start);
            Assert.Equal(0, response[1].TotalFail);
            Assert.Equal(1, response[1].TotalPass);
            Assert.Equal(1, response[1].TotalRun);
        }
        public async Task DifferentHosts()
        {
            // 1a & 1b are 2 instances (different machines) of the same host. They share.
            // 2 is a separate host.
            string     host1    = "h1-1"; // includes an tricky character that requires escaping.
            string     host2    = "h22";
            ILogWriter writer1a = LogFactory.NewWriter(host1, "c1", this);
            ILogWriter writer1b = LogFactory.NewWriter(host1, "c2", this);
            ILogWriter writer2  = LogFactory.NewWriter(host2, "c3", this);

            ILogReader reader1 = LogFactory.NewReader(this);
            ILogReader reader2 = LogFactory.NewReader(this);

            string Func1 = "alpha";

            var f1a = await QuickWriteAsync(writer1a, Func1); // first

            var f1b = await QuickWriteAsync(writer1b, Func1);

            var f1aa = await QuickWriteAsync(writer1a, Func1); // second write

            var f2 = await QuickWriteAsync(writer2, Func1);

            // Verify readers
            // Function definitions. Search all hosts if no host specified
            {
                var segment = await reader1.GetFunctionDefinitionsAsync(null, null);

                Assert.Equal(2, segment.Results.Length);
                var allDefinitions = segment.Results;

                segment = await reader1.GetFunctionDefinitionsAsync(host1, null);

                Assert.Single(segment.Results);
                var host1Defs = segment.Results[0];
                Assert.Equal(Func1, host1Defs.Name);
                Assert.Equal(FunctionId.Build(host1, Func1), host1Defs.FunctionId);

                segment = await reader1.GetFunctionDefinitionsAsync(host2, null);

                Assert.Single(segment.Results);
                var host2Defs = segment.Results[0];
                Assert.Equal(Func1, host2Defs.Name);
                Assert.Equal(FunctionId.Build(host2, Func1), host2Defs.FunctionId);

                Assert.Equal(Func1, allDefinitions[0].Name);
                Assert.Equal(Func1, allDefinitions[1].Name);
                Assert.Equal(host1Defs.FunctionId, allDefinitions[0].FunctionId);
                Assert.Equal(host2Defs.FunctionId, allDefinitions[1].FunctionId);
            }

            // Recent list
            {
                var segment = await reader1.GetRecentFunctionInstancesAsync(new RecentFunctionQuery
                {
                    FunctionId = FunctionId.Build(host1, Func1),
                    End        = DateTime.MaxValue,
                }, null);

                Guid[] guids = Array.ConvertAll(segment.Results, x => x.FunctionInstanceId);

                Assert.Equal(3, guids.Length); // Only include host 1
                Assert.Equal(f1a, guids[2]);   // reverse chronological
                Assert.Equal(f1b, guids[1]);
                Assert.Equal(f1aa, guids[0]);
            }

            // cross polination. Lookup across hosts.
            {
                var entry = await reader2.LookupFunctionInstanceAsync(f1a);

                Assert.NotNull(entry);
                Assert.Equal(entry.FunctionName, Func1);
            }
        }