Skip to content

Commit 207d7e9

Browse files
committed
Initial commit
0 parents  commit 207d7e9

File tree

8 files changed

+812
-0
lines changed

8 files changed

+812
-0
lines changed

.gitignore

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
*.vscode
5+
6+
# User-specific files
7+
*.suo
8+
*.user
9+
*.userosscache
10+
*.sln.docstates
11+
12+
# User-specific files (MonoDevelop/Xamarin Studio)
13+
*.userprefs
14+
15+
# Build results
16+
[Dd]ebug/
17+
[Dd]ebugPublic/
18+
[Rr]elease/
19+
[Rr]eleases/
20+
[Xx]64/
21+
[Xx]86/
22+
[Bb]uild/
23+
bld/
24+
[Bb]in/
25+
[Oo]bj/
26+
27+
# Visual Studio 2015 cache/options directory
28+
.vs/
29+
# Uncomment if you have tasks that create the project's static files in wwwroot
30+
#wwwroot/
31+
32+
# MSTest test Results
33+
[Tt]est[Rr]esult*/
34+
[Bb]uild[Ll]og.*
35+
36+
# NUNIT
37+
*.VisualState.xml
38+
TestResult.xml
39+
40+
# Build Results of an ATL Project
41+
[Dd]ebugPS/
42+
[Rr]eleasePS/
43+
dlldata.c
44+
45+
# DNX
46+
project.lock.json
47+
artifacts/
48+
49+
*_i.c
50+
*_p.c
51+
*_i.h
52+
*.ilk
53+
*.meta
54+
*.obj
55+
*.pch
56+
*.pdb
57+
*.pgc
58+
*.pgd
59+
*.rsp
60+
*.sbr
61+
*.tlb
62+
*.tli
63+
*.tlh
64+
*.tmp
65+
*.tmp_proj
66+
*.log
67+
*.vspscc
68+
*.vssscc
69+
.builds
70+
*.pidb
71+
*.svclog
72+
*.scc
73+
74+
# Chutzpah Test files
75+
_Chutzpah*
76+
77+
# Visual C++ cache files
78+
ipch/
79+
*.aps
80+
*.ncb
81+
*.opendb
82+
*.opensdf
83+
*.sdf
84+
*.cachefile
85+
*.VC.db
86+
87+
# Visual Studio profiler
88+
*.psess
89+
*.vsp
90+
*.vspx
91+
*.sap
92+
93+
# TFS 2012 Local Workspace
94+
$tf/
95+
96+
# Guidance Automation Toolkit
97+
*.gpState
98+
99+
# ReSharper is a .NET coding add-in
100+
_ReSharper*/
101+
*.[Rr]e[Ss]harper
102+
*.DotSettings.user
103+
104+
# JustCode is a .NET coding add-in
105+
.JustCode
106+
107+
# TeamCity is a build add-in
108+
_TeamCity*
109+
110+
# DotCover is a Code Coverage Tool
111+
*.dotCover
112+
113+
# NCrunch
114+
_NCrunch_*
115+
.*crunch*.local.xml
116+
nCrunchTemp_*
117+
118+
# MightyMoose
119+
*.mm.*
120+
AutoTest.Net/
121+
122+
# Web workbench (sass)
123+
.sass-cache/
124+
125+
# Installshield output folder
126+
[Ee]xpress/
127+
128+
# DocProject is a documentation generator add-in
129+
DocProject/buildhelp/
130+
DocProject/Help/*.HxT
131+
DocProject/Help/*.HxC
132+
DocProject/Help/*.hhc
133+
DocProject/Help/*.hhk
134+
DocProject/Help/*.hhp
135+
DocProject/Help/Html2
136+
DocProject/Help/html
137+
138+
# Click-Once directory
139+
publish/
140+
141+
# Publish Web Output
142+
*.[Pp]ublish.xml
143+
*.azurePubxml
144+
145+
# TODO: Un-comment the next line if you do not want to checkin
146+
# your web deploy settings because they may include unencrypted
147+
# passwords
148+
#*.pubxml
149+
*.publishproj
150+
151+
# NuGet Packages
152+
*.nupkg
153+
# The packages folder can be ignored because of Package Restore
154+
**/packages/*
155+
# except build/, which is used as an MSBuild target.
156+
!**/packages/build/
157+
# Uncomment if necessary however generally it will be regenerated when needed
158+
#!**/packages/repositories.config
159+
# NuGet v3's project.json files produces more ignoreable files
160+
*.nuget.props
161+
*.nuget.targets
162+
163+
# Microsoft Azure Build Output
164+
csx/
165+
*.build.csdef
166+
167+
# Microsoft Azure Emulator
168+
ecf/
169+
rcf/
170+
171+
# Windows Store app package directory
172+
AppPackages/
173+
BundleArtifacts/
174+
175+
# Visual Studio cache files
176+
# files ending in .cache can be ignored
177+
*.[Cc]ache
178+
# but keep track of directories ending in .cache
179+
!*.[Cc]ache/
180+
181+
# Others
182+
ClientBin/
183+
[Ss]tyle[Cc]op.*
184+
~$*
185+
*~
186+
*.dbmdl
187+
*.dbproj.schemaview
188+
*.pfx
189+
*.publishsettings
190+
node_modules/
191+
orleans.codegen.cs
192+
193+
# RIA/Silverlight projects
194+
Generated_Code/
195+
196+
# Backup & report files from converting an old project file
197+
# to a newer Visual Studio version. Backup files are not needed,
198+
# because we have git ;-)
199+
_UpgradeReport_Files/
200+
Backup*/
201+
UpgradeLog*.XML
202+
UpgradeLog*.htm
203+
204+
# SQL Server files
205+
*.mdf
206+
*.ldf
207+
208+
# Business Intelligence projects
209+
*.rdl.data
210+
*.bim.layout
211+
*.bim_*.settings
212+
213+
# Microsoft Fakes
214+
FakesAssemblies/
215+
216+
# GhostDoc plugin setting file
217+
*.GhostDoc.xml
218+
219+
# Node.js Tools for Visual Studio
220+
.ntvs_analysis.dat
221+
222+
# Visual Studio 6 build log
223+
*.plg
224+
225+
# Visual Studio 6 workspace options file
226+
*.opt
227+
228+
# Visual Studio LightSwitch build output
229+
**/*.HTMLClient/GeneratedArtifacts
230+
**/*.DesktopClient/GeneratedArtifacts
231+
**/*.DesktopClient/ModelManifest.xml
232+
**/*.Server/GeneratedArtifacts
233+
**/*.Server/ModelManifest.xml
234+
_Pvt_Extensions
235+
236+
# LightSwitch generated files
237+
GeneratedArtifacts/
238+
ModelManifest.xml
239+
240+
# Paket dependency manager
241+
.paket/paket.exe
242+
243+
# FAKE - F# Make
244+
.fake/

Camunda.Test.Example.csproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<BpmnFiles Include="bpmn/**/*.*" />
11+
</ItemGroup>
12+
<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
13+
<Copy SourceFiles="@(BpmnFiles)" DestinationFolder="$(OutDir)/bpmn" SkipUnchangedFiles="true" />
14+
</Target>
15+
16+
<ItemGroup>
17+
<PackageReference Include="Camunda.Api.Client" Version="2.5.1" />
18+
<PackageReference Include="Docker.DotNet" Version="3.125.2" />
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
20+
<PackageReference Include="NUnit" Version="3.12.0" />
21+
<PackageReference Include="Nunit3TestAdapter" Version="3.17.0" />
22+
</ItemGroup>
23+
24+
</Project>

ProcessEngine/DockerProcessEngine.cs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Runtime.InteropServices;
5+
using System.Threading;
6+
using Docker.DotNet;
7+
using Docker.DotNet.Models;
8+
9+
namespace Camunda.Test.Example.ProcessEngine
10+
{
11+
public class DockerProcessEngine
12+
{
13+
private DockerClient DockerClient;
14+
private string ContainerId;
15+
16+
public DockerProcessEngine()
17+
{
18+
DockerClient = BuildDockerClient();
19+
}
20+
21+
public void Start()
22+
{
23+
Console.WriteLine($"Building Camunda docker container");
24+
var progress = new Progress<JSONMessage>();
25+
DockerClient.Images.CreateImageAsync(
26+
new ImagesCreateParameters
27+
{
28+
FromImage = "camunda/camunda-bpm-platform:",
29+
Tag = "run-7.13.0",
30+
}, null, progress).Wait();
31+
32+
ContainerId = DockerClient.Containers.CreateContainerAsync(new CreateContainerParameters()
33+
{
34+
Name = "camunda-unit-test",
35+
Image = "camunda/camunda-bpm-platform:run-7.13.0",
36+
ExposedPorts = new Dictionary<string, EmptyStruct>
37+
{
38+
{
39+
"8080", default(EmptyStruct)
40+
},
41+
{
42+
"8000", default(EmptyStruct)
43+
},
44+
{
45+
"9404", default(EmptyStruct)
46+
}
47+
},
48+
HostConfig = new HostConfig
49+
{
50+
PortBindings = new Dictionary<string, IList<PortBinding>>
51+
{
52+
{"8080", new List<PortBinding> {new PortBinding {HostPort = "8090"}}},
53+
{"8000", new List<PortBinding> {new PortBinding {HostPort = "8000"}}},
54+
{"9404", new List<PortBinding> {new PortBinding {HostPort = "9404"}}}
55+
},
56+
PublishAllPorts = true
57+
}
58+
}).Result.ID;
59+
60+
DockerClient.Containers.StartContainerAsync(ContainerId, null).Wait();
61+
62+
var started = false;
63+
64+
while (!started)
65+
{
66+
Thread.Sleep(5000);
67+
Stream result = DockerClient.Containers.GetContainerLogsAsync(ContainerId, new ContainerLogsParameters()
68+
{
69+
ShowStdout = true
70+
}).Result;
71+
StreamReader reader = new StreamReader(result);
72+
started = reader.ReadToEnd().Contains("starting to acquire jobs");
73+
}
74+
}
75+
76+
public void Stop()
77+
{
78+
Console.WriteLine($"Stopping Camunda docker container");
79+
DockerClient.Containers.RemoveContainerAsync(ContainerId, new ContainerRemoveParameters()
80+
{
81+
RemoveVolumes = true,
82+
Force = true
83+
}).Wait();
84+
}
85+
86+
private DockerClient BuildDockerClient()
87+
{
88+
string url;
89+
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
90+
91+
if (isWindows)
92+
{
93+
url = "npipe://./pipe/docker_engine";
94+
}
95+
else
96+
{
97+
url = "unix:///var/run/docker.sock";
98+
}
99+
100+
return new DockerClientConfiguration(new Uri(url)).CreateClient();
101+
}
102+
103+
}
104+
}

0 commit comments

Comments
 (0)