Skip to content

Commit 93a6392

Browse files
ggallotticlaudiamurialdoGonzalo Gallotti Vazquez
authored
Add Local Stack for External Storage UnitTesting (#1095)
* Add Local Stack * Fix error * #Fix: MSBUILD : error MSB1009: Project file does not exist. * Run storage tests by creating a temporary solution containing only .NET 8 projects. * fix syntax error * Fix directory separator character * Fix casing issue. * Exclude extensions tests from temporary solution * Ensure compatibility with both Windows and Linux by normalizing path separators in the DumpProjectsAndCoreTests MSBuild task. * Install libgdiplus Fix System.TypeInitializationException : The type initializer for 'Gdip' threw an exception. System.DllNotFoundException : Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, * Skip ShellTest on non-Windows platforms * Remove hardcoded '.exe' from the dotnet executable to ensure compatibility across Windows and Linux environments * Prevent Windows-specific unit tests from running on Ubuntu by disabling them. * Prevent Windows-specific unit tests from running on Ubuntu by disabling them. Add missing file * Enable custom endpoint * Add S3_SKIP_URL_SIGNATURE_TEST environment variable to skip URL signature tests in External Storage Tests * [FIX] PDFTests in docker container * Fix syntax error. --------- Co-authored-by: Claudia Murialdo <cmurialdo@genexus.com> Co-authored-by: Gonzalo Gallotti Vazquez <g.gallotti@globant.com>
1 parent ddb68f1 commit 93a6392

File tree

12 files changed

+109
-47
lines changed

12 files changed

+109
-47
lines changed

.github/workflows/External-Storage-Tests.yml

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ jobs:
1717
GIT_REF: ${{ github.ref }}
1818
GIT_SHA: ${{ github.sha }}
1919
Configuration: Release
20-
SolutionFile: dotnet\DotNetStandardClasses.sln
20+
SolutionFile: dotnet\StorageTestSolution.sln
21+
SolutionFileName: StorageTestSolution
2122

22-
runs-on: windows-latest
23+
runs-on: ubuntu-latest
2324
environment: external-storage-tests
2425

2526
steps:
@@ -28,44 +29,71 @@ jobs:
2829
with:
2930
fetch-depth: 0
3031

32+
- name: Install Docker
33+
uses: docker/setup-buildx-action@v2
34+
35+
- name: Start LocalStack
36+
run: |
37+
docker run -d -p 4566:4566 -p 4572:4572 --name localstack localstack/localstack
38+
sleep 10 # Wait for LocalStack to initialize
39+
40+
- name: Configure AWS CLI for LocalStack
41+
run: |
42+
aws configure set aws_access_key_id test
43+
aws configure set aws_secret_access_key test
44+
aws configure set default.region us-east-1
45+
aws configure set endpoint_url http://localhost:4566
46+
47+
- name: Create S3 Bucket in LocalStack
48+
run: aws s3api create-bucket --bucket test-bucket --endpoint-url http://localhost:4566
49+
3150
- name: Install .NET 8
3251
uses: actions/setup-dotnet@v3
3352
with:
3453
dotnet-version: '8.x'
3554
include-prerelease: true
55+
56+
- name: Install libgdiplus
57+
run: sudo apt-get install -y libgdiplus
3658

59+
- name: Create temporary solution with .NET 8 projects
60+
run: |
61+
dotnet new sln --name $SolutionFileName --output dotnet --force
62+
dotnet msbuild dotnet/DotNetStandardClasses.sln /t:DumpProjectsAndCoreTests -p:DumpSolutionName=$SolutionFileName /m:1 -p:DumpSolutionTargetFrameworkDefault=net8
63+
3764
- name: Restore packages
38-
run: dotnet restore $Env:SolutionFile
65+
run: dotnet restore $SolutionFile
3966

4067
- name: Build
41-
run: dotnet build $Env:SolutionFile --no-restore --configuration $Env:Configuration
68+
run: dotnet build $SolutionFile --no-restore --configuration $Configuration
4269

4370
- name: Test External Storage
44-
run: |
45-
$Env:AWSS3_TEST_ENABLED="true"
46-
$Env:STORAGE_AWSS3_ACCESS_KEY="${{ secrets.AWSS3_ACCESS_KEY }}"
47-
$Env:STORAGE_AWSS3_SECRET_KEY="${{ secrets.AWSS3_SECRET_KEY }}"
48-
$Env:STORAGE_AWSS3_BUCKET_NAME="genexus-s3-test"
49-
$Env:STORAGE_AWSS3_FOLDER_NAME="gxclasses"
50-
$Env:STORAGE_AWSS3_REGION="us-east-1"
51-
$Env:IBMCOS_TEST_ENABLED="true"
52-
$Env:STORAGE_IBMCOS_ACCESS_KEY="${{ secrets.IBMCOS_ACCESS_KEY }}"
53-
$Env:STORAGE_IBMCOS_SECRET_KEY="${{ secrets.IBMCOS_SECRET_KEY }}"
54-
$Env:STORAGE_IBMCOS_BUCKET_NAME="gxclasses-unit-tests"
55-
$Env:STORAGE_IBMCOS_FOLDER_NAME="tests"
56-
$Env:STORAGE_IBMCOS_REGION="us-south"
57-
$Env:AZUREBS_TEST_ENABLED="true"
58-
$Env:STORAGE_AZUREBS_ACCESS_KEY="${{ secrets.AZUREBS_ACCESS_KEY }}"
59-
$Env:STORAGE_AZUREBS_ACCOUNT_NAME="${{ secrets.AZUREBS_ACCOUNT_NAME }}"
60-
$Env:STORAGE_AZUREBS_FOLDER_NAME="tests"
61-
$Env:STORAGE_AZUREBS_PUBLIC_CONTAINER_NAME="contluispublic"
62-
$Env:STORAGE_AZUREBS_PRIVATE_CONTAINER_NAME="contluisprivate"
63-
$Env:GOOGLECS_TEST_ENABLED="true"
64-
$Env:STORAGE_GOOGLECS_KEY='${{ secrets.GOOGLECS_KEY }}'
65-
$Env:STORAGE_GOOGLECS_PROJECT_ID="gxjavacloudstorageunittests"
66-
$Env:STORAGE_GOOGLECS_BUCKET_NAME="javaclasses-unittests"
67-
$Env:STORAGE_GOOGLECS_FOLDER_NAME="gxclasses"
68-
$Env:STORAGE_GOOGLECS_APPLICATION_NAME="gxjavacloudstorageunittests"
69-
70-
dotnet test $Env:SolutionFile --no-restore --no-build --configuration $Env:Configuration
71-
71+
env:
72+
AWSS3_TEST_ENABLED: "true"
73+
STORAGE_AWSS3_ACCESS_KEY: "test"
74+
STORAGE_AWSS3_SECRET_KEY: "test"
75+
STORAGE_AWSS3_BUCKET_NAME: "test-bucket"
76+
STORAGE_AWSS3_FOLDER_NAME: "gxclasses"
77+
STORAGE_AWSS3_REGION: "us-east-1"
78+
STORAGE_AWSS3_ENDPOINT: "custom"
79+
S3_SKIP_URL_SIGNATURE_TEST: "true"
80+
STORAGE_AWSS3_CUSTOM_ENDPOINT: "http://localhost:4566"
81+
IBMCOS_TEST_ENABLED: "true"
82+
STORAGE_IBMCOS_ACCESS_KEY: "${{ secrets.IBMCOS_ACCESS_KEY }}"
83+
STORAGE_IBMCOS_SECRET_KEY: "${{ secrets.IBMCOS_SECRET_KEY }}"
84+
STORAGE_IBMCOS_BUCKET_NAME: "gxclasses-unit-tests"
85+
STORAGE_IBMCOS_FOLDER_NAME: "tests"
86+
STORAGE_IBMCOS_REGION: "us-south"
87+
AZUREBS_TEST_ENABLED: "true"
88+
STORAGE_AZUREBS_ACCESS_KEY: "${{ secrets.AZUREBS_ACCESS_KEY }}"
89+
STORAGE_AZUREBS_ACCOUNT_NAME: "${{ secrets.AZUREBS_ACCOUNT_NAME }}"
90+
STORAGE_AZUREBS_FOLDER_NAME: "tests"
91+
STORAGE_AZUREBS_PUBLIC_CONTAINER_NAME: "contluispublic"
92+
STORAGE_AZUREBS_PRIVATE_CONTAINER_NAME: "contluisprivate"
93+
GOOGLECS_TEST_ENABLED: "true"
94+
STORAGE_GOOGLECS_KEY: '${{ secrets.GOOGLECS_KEY }}'
95+
STORAGE_GOOGLECS_PROJECT_ID: "gxjavacloudstorageunittests"
96+
STORAGE_GOOGLECS_BUCKET_NAME: "javaclasses-unittests"
97+
STORAGE_GOOGLECS_FOLDER_NAME: "gxclasses"
98+
STORAGE_GOOGLECS_APPLICATION_NAME: "gxjavacloudstorageunittests"
99+
run: dotnet test $SolutionFile --no-restore --no-build --configuration $Configuration

dotnet/Directory.Build.targets

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
<Copy SourceFiles="$(ProjectDir)$(OutDir)$(TargetName).pdb" DestinationFolder="$(DeployDirectory)" Condition="'$(Configuration)'=='Debug'" />
2424
</Target>
2525

26-
<Target Name="DumpProjects" Condition="($(TargetFramework.StartsWith($(DumpSolutionTargetFrameworkDefault))) OR $(TargetFrameworks.Contains($(DumpSolutionTargetFrameworkDefault))) ) AND !$(MSBuildProjectFullPath.Contains('\test\')) AND ('$(IsPublishable)'=='true' OR '$(IsPublishable)'=='')">
26+
<Target Name="DumpProjects" Condition="($(TargetFramework.StartsWith($(DumpSolutionTargetFrameworkDefault))) OR $(TargetFrameworks.Contains($(DumpSolutionTargetFrameworkDefault))) ) AND !$(MSBuildProjectFullPath.Replace('\', '/').Contains('/test/')) AND ('$(IsPublishable)'=='true' OR '$(IsPublishable)'=='')">
27+
<Exec Command="dotnet sln $(MSBuildThisFileDirectory)$(DumpSolutionName).sln add $(MSBuildProjectFullPath)"></Exec>
28+
</Target>
29+
30+
<Target Name="DumpProjectsAndCoreTests" Condition="($(TargetFramework.StartsWith($(DumpSolutionTargetFrameworkDefault))) OR $(TargetFrameworks.Contains($(DumpSolutionTargetFrameworkDefault))) ) AND !$(MSBuildProjectFullPath.Replace('\', '/').Contains('/extensions/'))">
2731
<Exec Command="dotnet sln $(MSBuildThisFileDirectory)$(DumpSolutionName).sln add $(MSBuildProjectFullPath)"></Exec>
2832
</Target>
2933

dotnet/src/dotnetcore/GxDataInitialization/GXDataInitialization.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);CustomContentTarget</TargetsForTfmSpecificContentInPackage>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<Compile Include="..\..\dotnetframework\GXDataInitialization\GXDataInitialization.cs" Link="GXDataInitialization.cs" />
12+
<Compile Include="..\..\dotnetframework\GxDataInitialization\GXDataInitialization.cs" Link="GXDataInitialization.cs" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

dotnet/test/DotNetCoreUnitTest/DotNetCoreUnitTest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<ItemGroup>
4040
<Compile Include="..\DotNetUnitTest\ImageUtils\ImageUtilTest.cs" Link="ImageUtils\ImageUtilTest.cs" />
4141
<Compile Include="..\DotNetUnitTest\StringUtil\StringUtilTests.cs" Link="StringUtil\StringUtilTests.cs" />
42+
<Compile Include="..\DotNetUnitTest\WindowOnlyFact.cs" Link="WindowOnlyFact.cs" />
4243

4344
</ItemGroup>
4445
<ItemGroup>

dotnet/test/DotNetPdfTest/PDFTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ public class PDFTests
1111
public void TestITextFormat()
1212
{
1313
string report = "PDFFormat.pdf";
14-
string outputFileDirectory = @".\temp\";
14+
string outputFileDirectory = "temp";
1515

1616
string reportFullPath = Path.Combine(Directory.GetCurrentDirectory(), outputFileDirectory, report);
17+
Directory.CreateDirectory(Path.GetDirectoryName(reportFullPath));
18+
1719
if (File.Exists(reportFullPath))
1820
File.Delete(reportFullPath);
1921
try

dotnet/test/DotNetUnitTest/Domain/GxHttpClientTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Net;
66
using System.Net.Http;
77
using System.Threading.Tasks;
8+
using DotNetUnitTest;
89
using GeneXus.Application;
910
using GeneXus.Http.Client;
1011
using Xunit;
@@ -54,7 +55,7 @@ public void HttpClientInvalidURLWithCustomPort()
5455
}
5556
}
5657

57-
[Fact]
58+
[WindowsOnlyFact]
5859
public void HttpClientCookieHeader()
5960
{
6061
string headerValue = "CognitoIdentityServiceProvider.3tgmin25m9bkg6vgi7vpavu7a9.M00000936.refreshToken=eyJjdHkiOiJKV1QiLCJlbmMiSkRCAmMpYqndvORnWLTfHw; CognitoIdentityServiceProvider.3tgmin25m9bkg6vgi7vpavu7a9.LastAuthUser=M00000936";

dotnet/test/DotNetUnitTest/Domain/ShellTest.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.IO;
2+
using DotNetUnitTest;
23
using GeneXus.Utils;
34
using Xunit;
45

@@ -7,15 +8,15 @@ namespace xUnitTesting
78

89
public class ShellTest
910
{
10-
[Fact]
11+
[WindowsOnlyFact]
1112
public void ExecutableTest()
1213
{
1314
string fileName = "hello.bat";
1415
File.WriteAllText(fileName, "echo \"hello %1\"");
1516
int errorCode = GXUtil.Shell($"{fileName} test", 1, 1);
1617
Assert.Equal(0, errorCode);
1718
}
18-
[Fact]
19+
[WindowsOnlyFact]
1920
public void ExecutableWithSpacesTest()
2021
{
2122
string fileName = "hello world.bat";
@@ -24,7 +25,7 @@ public void ExecutableWithSpacesTest()
2425
Assert.Equal(0, errorCode);
2526
}
2627

27-
[Fact]
28+
[WindowsOnlyFact]
2829
public void WorkingDirWithSpacesTest()
2930
{
3031
string fileName = Path.Combine(Directory.GetCurrentDirectory(), "my dir", "hello world.bat");
@@ -34,7 +35,7 @@ public void WorkingDirWithSpacesTest()
3435
int errorCode = GXUtil.Shell($"'{fileName}' test", 1, 1);
3536
Assert.Equal(0, errorCode);
3637
}
37-
[Fact]
38+
[WindowsOnlyFact]
3839
public void WorkingDirForFullQualifiedBat()
3940
{
4041
string pathName = Directory.GetParent(Directory.GetCurrentDirectory()).FullName; //bat is in a different directory to the current dir

dotnet/test/DotNetUnitTest/ExternalProvider/ExternalProviderTest.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,15 @@ private static void Wait(int milliseconds)
393393
private void EnsureUrl(String signedOrUnsignedUrl, GxFileType acl)
394394
{
395395
Assert.True(UrlExists(signedOrUnsignedUrl), "URL not found: " + signedOrUnsignedUrl);
396-
if (IsPrivateFile(acl))
396+
397+
bool skipUrlSignatureTests = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("S3_SKIP_URL_SIGNATURE_TEST"));
398+
if (skipUrlSignatureTests)
397399
{
400+
return;
401+
}
402+
403+
if (IsPrivateFile(acl))
404+
{
398405
if (!(this is ExternalProviderMinioTest)) //Minio local installation not supported
399406
{
400407
Skip.If(this is ExternalProviderMinioTest);

dotnet/test/DotNetUnitTest/FileIO/FileIOTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using DotNetUnitTest;
34
using GeneXus.Configuration;
45
using GeneXus.Printer;
56
using GeneXus.Utils;
@@ -13,7 +14,7 @@ public FileIOTests()
1314
{
1415
Config.ConfigFileName = Path.Combine(BaseDir, "client.exe.config");
1516
}
16-
[Fact]
17+
[WindowsOnlyFact]
1718
public void FileSharedToCopy()
1819
{
1920
string target = @"\\192.168.86.3\printer";
@@ -23,7 +24,7 @@ public void FileSharedToCopy()
2324
Assert.Equal(-1, f.ErrCode);
2425
Assert.NotEqual(new NullReferenceException().Message, f.ErrDescription);
2526
}
26-
[Fact]
27+
[WindowsOnlyFact]
2728
public void FileSourceTest()
2829
{
2930
GxFileInfo fi = new GxFileInfo(string.Empty);
@@ -79,7 +80,7 @@ public void GXDBFilePathTest()
7980
}
8081
}
8182

82-
[Fact]
83+
[WindowsOnlyFact]
8384
public void PathUtilGetValidFileName()
8485
{
8586
string path = "file:///C:/Models/Upload/CSharpModel/web/PublicTempStorage/multimedia/Screen%20Shot%202016-02-15%20at%2011.41.55%20AM_ff107a3ba9fb4564bb4e1bf7f74d5fbf.png";

dotnet/test/DotNetUnitTest/PDF/PDFTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Reflection;
55
using System.Threading.Tasks;
66
using com.genexus.reports;
7+
using DotNetUnitTest;
78
using GeneXus.Programs;
89
using GeneXus.Utils;
910
using Xunit;
@@ -27,7 +28,7 @@ public void ConcurrencyPDFSearchPaths()
2728
});
2829

2930
}
30-
[Fact]
31+
[WindowsOnlyFact]
3132
public void ExtractTextFromPDF()
3233
{
3334
string text = DocumentHandler.GetText("sample.pdf", "pdf");

0 commit comments

Comments
 (0)