Repository: featbit/featbit (language: python)

Issue:
[build] cannot build evaluation server image
<img width="942" alt="image" src="https://user-images.githubusercontent.com/34052208/190082397-e19bd2c0-6d3a-4670-94a7-a37352117605.png">


Discussion / hints:

Fix patch:
diff --git a/modules/evaluation-server/EvaluationServer.sln b/modules/evaluation-server/EvaluationServer.sln
index bda2ce34d..abb90b9e8 100644
--- a/modules/evaluation-server/EvaluationServer.sln
+++ b/modules/evaluation-server/EvaluationServer.sln
@@ -21,10 +21,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application.UnitTests", "te
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application.IntegrationTests", "tests\Application.IntegrationTests\Application.IntegrationTests.csproj", "{9A4D64CB-587B-428F-9075-E134DE451110}"
 EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "perf", "perf", "{A3CF728D-9B1E-4167-BA89-363760FCB8EB}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "perf\Benchmarks\Benchmarks.csproj", "{FBF517B5-CD08-423D-A657-A3222BADE032}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestBase", "tests\TestBase\TestBase.csproj", "{F587EA9E-3453-45AF-9CD5-F4FBE8B7C7B2}"
 EndProject
 Global
@@ -43,7 +39,6 @@ Global
 		{2285E659-F1F6-4F65-A00D-9E766B60ABBF} = {3A631AD4-F16D-49F4-B3E7-D46F47F38782}
 		{954667D5-3309-4B79-9180-5E60FCCD9B43} = {3A631AD4-F16D-49F4-B3E7-D46F47F38782}
 		{9A4D64CB-587B-428F-9075-E134DE451110} = {3A631AD4-F16D-49F4-B3E7-D46F47F38782}
-		{FBF517B5-CD08-423D-A657-A3222BADE032} = {A3CF728D-9B1E-4167-BA89-363760FCB8EB}
 		{F587EA9E-3453-45AF-9CD5-F4FBE8B7C7B2} = {3A631AD4-F16D-49F4-B3E7-D46F47F38782}
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
@@ -75,10 +70,6 @@ Global
 		{9A4D64CB-587B-428F-9075-E134DE451110}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{9A4D64CB-587B-428F-9075-E134DE451110}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{9A4D64CB-587B-428F-9075-E134DE451110}.Release|Any CPU.Build.0 = Release|Any CPU
-		{FBF517B5-CD08-423D-A657-A3222BADE032}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{FBF517B5-CD08-423D-A657-A3222BADE032}.Release|Any CPU.Build.0 = Release|Any CPU
-		{FBF517B5-CD08-423D-A657-A3222BADE032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{FBF517B5-CD08-423D-A657-A3222BADE032}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{F587EA9E-3453-45AF-9CD5-F4FBE8B7C7B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{F587EA9E-3453-45AF-9CD5-F4FBE8B7C7B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{F587EA9E-3453-45AF-9CD5-F4FBE8B7C7B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/modules/evaluation-server/depoly/Dockerfile b/modules/evaluation-server/depoly/Dockerfile
index 5b3a5f48e..333009a0a 100644
--- a/modules/evaluation-server/depoly/Dockerfile
+++ b/modules/evaluation-server/depoly/Dockerfile
@@ -3,16 +3,18 @@
 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
 WORKDIR /source
 
-# copy csproj and restore as distinct layers
+# copy sln
 COPY *.sln .
-COPY src/Domain/*.csproj src/Domain/
-COPY src/Application/*.csproj src/Application/
-COPY src/Infrastructure/*.csproj src/Infrastructure/
-COPY src/Api/*.csproj src/Api/
-COPY tests/Domain.UnitTests/*.csproj tests/Domain.UnitTests/
-COPY tests/Application.UnitTests/*.csproj tests/Application.UnitTests/
-COPY tests/Application.IntegrationTests/*.csproj tests/Application.IntegrationTests/
-RUN dotnet restore
+
+# copy src project files
+COPY src/*/*.csproj ./
+RUN for file in $(ls *.csproj); do mkdir -p src/${file%.*}/ && mv $file src/${file%.*}/; done
+
+# copy test project files
+COPY tests/*/*.csproj ./
+RUN for file in $(ls *.csproj); do mkdir -p tests/${file%.*}/ && mv $file tests/${file%.*}/; done
+
+RUN dotnet restore 
 
 # copy all source, build and test
 COPY . .
diff --git a/modules/evaluation-server/src/Domain/Utils/ExtensionMethods/DataTimeExtensions.cs b/modules/evaluation-server/src/Domain/Utils/ExtensionMethods/DataTimeExtensions.cs
deleted file mode 100644
index 824ee5693..000000000
--- a/modules/evaluation-server/src/Domain/Utils/ExtensionMethods/DataTimeExtensions.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-﻿namespace Domain.Utils.ExtensionMethods;
-
-public static class DateTimeExtensions
-{
-    public static long ToUnixTimeMilliseconds(this DateTime dateTime)
-    {
-        var milliseconds = new DateTimeOffset(dateTime).ToUnixTimeMilliseconds();
-
-        return milliseconds;
-    }
-}
\ No newline at end of file
diff --git a/modules/evaluation-server/src/Domain/WebSockets/RequestHandler.cs b/modules/evaluation-server/src/Domain/WebSockets/RequestHandler.cs
index 67bea80eb..a36793d31 100644
--- a/modules/evaluation-server/src/Domain/WebSockets/RequestHandler.cs
+++ b/modules/evaluation-server/src/Domain/WebSockets/RequestHandler.cs
@@ -1,6 +1,5 @@
 using System.Net.WebSockets;
 using Domain.Core;
-using Domain.Utils.ExtensionMethods;
 
 namespace Domain.WebSockets;
 
@@ -34,7 +33,7 @@ public class RequestHandler
         }
 
         // token timestamp
-        var current = currentTimestamp ?? DateTime.UtcNow.ToUnixTimeMilliseconds();
+        var current = currentTimestamp ?? DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
         if (Math.Abs(current - token.Timestamp) > 30 * 1000)
         {
             return null;


Test patch:
diff --git a/modules/evaluation-server/tests/Application.IntegrationTests/TestApp.cs b/modules/evaluation-server/tests/Application.IntegrationTests/TestApp.cs
index e92b619a8..a67e488db 100644
--- a/modules/evaluation-server/tests/Application.IntegrationTests/TestApp.cs
+++ b/modules/evaluation-server/tests/Application.IntegrationTests/TestApp.cs
@@ -1,7 +1,37 @@
-﻿using Microsoft.AspNetCore.Mvc.Testing;
+﻿using System.Net.WebSockets;
+using Microsoft.AspNetCore.Mvc.Testing;
+using Microsoft.AspNetCore.TestHost;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using Microsoft.Extensions.Internal;
 
 namespace Application.IntegrationTests;
 
 public class TestApp : WebApplicationFactory<Program>
 {
+    public async Task<WebSocket> ConnectAsync(long timestamp = 0, string queryString = "")
+    {
+        var streamingApp = WithWebHostBuilder(builder =>
+        {
+            builder.ConfigureTestServices(collection =>
+            {
+                collection.Replace(ServiceDescriptor.Singleton<ISystemClock>(new TestClock(timestamp)));
+            });
+        });
+
+        var client = streamingApp.Server.CreateWebSocketClient();
+        var streamingUri = new Uri($"http://localhost/streaming{queryString}");
+
+        var ws = await client.ConnectAsync(streamingUri, CancellationToken.None);
+        return ws;
+    }
+    
+    public async Task<WebSocket> ConnectWithTokenAsync()
+    {
+        const string token =
+            "QPXBHMWIxLWQ0NWUtNCUyMDIyMDgwMjA2MzUzNl9fMTYxX18yMDRQQBDDBUQXBHXXQDfXzQyMV9fZGVmYXVsdF84ZDBmZQ";
+        const long tokenCreatedAt = 1661907157706;
+
+        return await ConnectAsync(tokenCreatedAt, $"?type=client&version=2&token={token}");
+    }
 }
\ No newline at end of file
diff --git a/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/ConnectionTests.cs b/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/ConnectionTests.cs
index 96090495a..7694c088f 100644
--- a/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/ConnectionTests.cs
+++ b/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/ConnectionTests.cs
@@ -4,24 +4,24 @@ namespace Application.IntegrationTests.WebSockets;
 
 public class ConnectionTests : IClassFixture<TestApp>
 {
-    private readonly StreamingTestApp _app;
+    private readonly TestApp _app;
 
     public ConnectionTests(TestApp app)
     {
-        _app = new StreamingTestApp(app);
+        _app = app;
     }
-    
+
     [Fact]
     public async Task ConnectToServer()
     {
-        using var ws = await _app.ConnectAsync();
+        var ws = await _app.ConnectAsync();
         Assert.Equal(WebSocketState.Open, ws.State);
     }
-    
+
     [Fact]
     public async Task CloseInvalidConnection()
     {
-        using var ws = await _app.ConnectAsync();
+        var ws = await _app.ConnectAsync();
 
         var res = await ws.ReceiveAsync(new byte[100], CancellationToken.None);
 
diff --git a/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/EchoTests.cs b/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/EchoTests.cs
index 5d5a0e345..5c9ec5b1f 100644
--- a/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/EchoTests.cs
+++ b/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/EchoTests.cs
@@ -5,11 +5,11 @@ namespace Application.IntegrationTests.WebSockets;
 
 public class EchoTests : IClassFixture<TestApp>
 {
-    private readonly StreamingTestApp _app;
+    private readonly TestApp _app;
 
     public EchoTests(TestApp app)
     {
-        _app = new StreamingTestApp(app);
+        _app = app;
     }
 
     [Theory]
@@ -17,7 +17,7 @@ public EchoTests(TestApp app)
     [InlineData(false)]
     public async Task DoEchoAsync(bool multiFragment)
     {
-        using var ws = await _app.ConnectWithTokenAsync();
+        var ws = await _app.ConnectWithTokenAsync();
         
         const string message = "hello, world!";
         var payload = Encoding.UTF8.GetBytes(message);
diff --git a/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/ProcessMessageTests.cs b/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/ProcessMessageTests.cs
deleted file mode 100644
index bbce7f86b..000000000
--- a/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/ProcessMessageTests.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System.Net.WebSockets;
-
-namespace Application.IntegrationTests.WebSockets;
-
-// TODO: Add Asserts
-public class ProcessMessageTests : IClassFixture<TestApp>
-{
-    private readonly StreamingTestApp _app;
-
-    public ProcessMessageTests(TestApp app)
-    {
-        _app = new StreamingTestApp(app);
-    }
-
-    [Fact]
-    public async Task ProcessEmptyMessage()
-    {
-        var ws = await _app.ConnectWithTokenAsync();
-        await ws.SendAsync(ArraySegment<byte>.Empty, WebSocketMessageType.Text, true, CancellationToken.None);
-    }
-
-    [Fact]
-    public async Task ProcessInconsistentMessageFragment()
-    {
-        using var ws = await _app.ConnectWithTokenAsync();
-
-        await ws.SendAsync(new byte[] { 0x0, 0x1, 0x2 }, WebSocketMessageType.Text, false, CancellationToken.None);
-        await ws.SendAsync(new byte[] { 0x3, 0x4 }, WebSocketMessageType.Text, false, CancellationToken.None);
-        await ws.SendAsync(new byte[] { 0x5, 0x6, 0x7 }, WebSocketMessageType.Text, false, CancellationToken.None);
-        await ws.SendAsync(new byte[] { 0x8 }, WebSocketMessageType.Binary, true, CancellationToken.None);
-    }
-
-    [Fact]
-    public async Task ProcessTooManyMessageFragment()
-    {
-        using var ws = await _app.ConnectWithTokenAsync();
-
-        const int maxMessageFragment = 8;
-        for (byte i = 0; i < maxMessageFragment; i++)
-        {
-            await ws.SendAsync(new[] { i }, WebSocketMessageType.Text, false, CancellationToken.None);
-        }
-        
-        await ws.SendAsync(new byte[] { 0x8 }, WebSocketMessageType.Text, true, CancellationToken.None);
-    }
-}
\ No newline at end of file
diff --git a/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/StreamingTestApp.cs b/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/StreamingTestApp.cs
deleted file mode 100644
index a94ab619a..000000000
--- a/modules/evaluation-server/tests/Application.IntegrationTests/WebSockets/StreamingTestApp.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-﻿using System.Net.WebSockets;
-using Domain.WebSockets;
-using Microsoft.AspNetCore.TestHost;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.DependencyInjection.Extensions;
-using Microsoft.Extensions.Internal;
-using TestBase;
-
-namespace Application.IntegrationTests.WebSockets;
-
-public class StreamingTestApp
-{
-    private readonly TestApp _app;
-
-    public StreamingTestApp(TestApp app)
-    {
-        _app = app;
-    }
-
-    public async Task<WebSocket> ConnectAsync(long timestamp = 0, string queryString = "")
-    {
-        var streamingApp = _app.WithWebHostBuilder(builder => builder.ConfigureTestServices(collection =>
-        {
-            collection.Replace(ServiceDescriptor.Singleton<ISystemClock>(new TestClock(timestamp)));
-            collection.Replace(ServiceDescriptor.Scoped(_ => GetConnectionHandler()));
-        }));
-
-        var client = streamingApp.Server.CreateWebSocketClient();
-        var streamingUri = new Uri($"http://localhost/streaming{queryString}");
-
-        var ws = await client.ConnectAsync(streamingUri, CancellationToken.None);
-        return ws;
-    }
-
-    public async Task<WebSocket> ConnectWithTokenAsync()
-    {
-        const string token =
-            "QPXBHMWIxLWQ0NWUtNCUyMDIyMDgwMjA2MzUzNl9fMTYxX18yMDRQQBDDBUQXBHXXQDfXzQyMV9fZGVmYXVsdF84ZDBmZQ";
-
-        const long tokenCreatedAt = 1661907157706;
-
-        return await ConnectAsync(tokenCreatedAt, $"?type=client&version=2&token={token}");
-    }
-
-    ConnectionHandler GetConnectionHandler()
-    {
-        var manager = new ConnectionManager(new InMemoryFakeLogger<ConnectionManager>());
-        var handler = new ConnectionHandler(manager, new InMemoryFakeLogger<ConnectionHandler>())
-        {
-            CancellationToken = CancellationToken.None
-        };
-
-        return handler;
-    }
-}
\ No newline at end of file
diff --git a/modules/evaluation-server/tests/Domain.UnitTests/Utils/DateTimeExtensionTests.cs b/modules/evaluation-server/tests/Domain.UnitTests/Utils/DateTimeExtensionTests.cs
deleted file mode 100644
index 96c3a15bb..000000000
--- a/modules/evaluation-server/tests/Domain.UnitTests/Utils/DateTimeExtensionTests.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-﻿using Domain.Utils.ExtensionMethods;
-
-namespace Domain.UnitTests.Utils;
-
-public class DateTimeExtensionTests
-{
-    [Fact]
-    public void Should_Get_Timestamp_In_MillionSeconds()
-    {
-        var time = DateTime.Parse("2022-09-01 08:00:00");
-        
-        Assert.Equal(1661990400000, time.ToUnixTimeMilliseconds());
-    }
-}
\ No newline at end of file