@@ -5,12 +5,9 @@ function commonSetupOnce(testCase)
55
66% file definitions
77otelcolroot = getenv(" OPENTELEMETRY_COLLECTOR_INSTALL" );
8- assert(~isempty(otelcolroot ), " OPENTELEMETRY_COLLECTOR_INSTALL environment must be defined." )
98testCase.OtelConfigFile = fullfile(fileparts(mfilename(" fullpath" )), ...
109 " otelcol_config.yml" );
1110otelroot = getenv(" OPENTELEMETRY_MATLAB_INSTALL" );
12- assert(~isempty(otelroot ), " OPENTELEMETRY_MATLAB_INSTALL environment must be defined." )
13- testCase.OtelRoot = otelroot ;
1411testCase.JsonFile = " myoutput.json" ;
1512testCase.PidFile = " testoutput.txt" ;
1613
@@ -19,7 +16,13 @@ function commonSetupOnce(testCase)
1916if ispc
2017 testCase.ListPid = @(name )"tasklist / fi " " IMAGENAME eq " + name + " .exe"" " ;
2118 testCase.ReadPidList = @(file )readtable(file , " VariableNamingRule" , " preserve" , " NumHeaderLines" , 3 , " MultipleDelimsAsOne" , true , " Delimiter" , " " );
22- testCase.ExtractPid = @(table )table .Var2 ;
19+ testCase.ExtractPid = @(table )table .Var2 ;
20+
21+ % variables to support downloading OpenTelemetry Collector
22+ otelcol_arch_name = " windows_amd64" ;
23+ otelcol_exe_ext = " .exe" ;
24+
25+ % windows_kill
2326 windows_killroot = getenv(" WINDOWS_KILL_INSTALL" );
2427 windows_killname = " windows-kill" ;
2528 if isempty(windows_killroot )
@@ -41,6 +44,10 @@ function commonSetupOnce(testCase)
4144 testCase.ExtractPid = @(table )table .PID ;
4245 testCase.Sigint = @(id )"kill " + id; % kill sends a SIGTERM instead of SIGINT but turns out this is sufficient to terminate OTEL collector on Linux
4346 testCase.Sigterm = @(id)" kill " + id ;
47+
48+ % variables to support downloading OpenTelemetry Collector
49+ otelcol_arch_name = " linux_amd64" ;
50+ otelcol_exe_ext = " " ;
4451elseif ismac
4552 testCase.ListPid = @(name )"pgrep - x " + name;
4653 testCase.ReadPidList = @readmatrix;
@@ -53,10 +60,31 @@ function commonSetupOnce(testCase)
5360 end
5461
5562end
63+
64+ % OpenTelemetry Collector
65+ if isempty(otelcolroot )
66+ % collector not pre-installed
67+ otelcol_version = " 0.85.0" ;
68+ otelcol_url = " https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v" ...
69+ + otelcol_version ;
70+ otelcol_zipfilename = " otelcol_" + otelcol_version + " _" + otelcol_arch_name ;
71+ otelcolroot = fullfile(tempdir , otelcol_zipfilename );
72+
73+ % look for it in tempdir, download and install if it doesn't exist
74+ if ~exist(fullfile(otelcolroot , testCase .OtelcolName + otelcol_exe_ext )," file" )
75+ otelcol_tar = gunzip(fullfile(otelcol_url , otelcol_zipfilename + " .tar.gz" ), otelcolroot );
76+ otelcol_tar = otelcol_tar{1 }; % should have only extracted 1 tar file
77+ untar(otelcol_tar , otelcolroot );
78+ delete(otelcol_tar );
79+ end
80+ end
81+
5682testCase.Otelcol = fullfile(otelcolroot , testCase .OtelcolName );
5783
5884% set up path
59- testCase .applyFixture(matlab .unittest .fixtures .PathFixture(testCase .OtelRoot ));
85+ if ~isempty(otelroot )
86+ testCase .applyFixture(matlab .unittest .fixtures .PathFixture(otelroot ));
87+ end
6088
6189% remove temporary files if present
6290if exist(testCase .JsonFile , " file" )
0 commit comments