Skip to content

Commit 27953ad

Browse files
committed
Change tests to automatically download collector if not installed
1 parent c573ada commit 27953ad

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

test/commonSetupOnce.m

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ function commonSetupOnce(testCase)
1212
testCase.PidFile = "testoutput.txt";
1313

1414
% process definitions
15-
testCase.OtelcolName = "otelcol";
1615
if ispc
1716
testCase.ListPid = @(name)"tasklist /fi ""IMAGENAME eq " + name + ".exe""";
1817
testCase.ReadPidList = @(file)readtable(file, "VariableNamingRule", "preserve", "NumHeaderLines", 3, "MultipleDelimsAsOne", true, "Delimiter", " ");
@@ -55,13 +54,16 @@ function commonSetupOnce(testCase)
5554
testCase.Sigint = @(id)"kill -s INT " + id;
5655
testCase.Sigterm = @(id)"kill -s TERM " + id;
5756
if computer == "MACA64"
58-
% only the contrib version of OpenTelemetry Collector is available on Apple silicon
59-
testCase.OtelcolName = "otelcol-contrib";
57+
otelcol_arch_name = "darwin_arm64";
58+
else
59+
otelcol_arch_name = "darwin_amd64";
6060
end
61+
otelcol_exe_ext = "";
6162

6263
end
6364

6465
% OpenTelemetry Collector
66+
otelcolname = "otelcol";
6567
if isempty(otelcolroot)
6668
% collector not pre-installed
6769
otelcol_version = "0.85.0";
@@ -71,13 +73,21 @@ function commonSetupOnce(testCase)
7173
otelcolroot = fullfile(tempdir, otelcol_zipfilename);
7274

7375
% look for it in tempdir, download and install if it doesn't exist
74-
if ~exist(fullfile(otelcolroot, testCase.OtelcolName + otelcol_exe_ext),"file")
76+
if ~(exist(fullfile(otelcolroot, otelcolname + otelcol_exe_ext),"file") || ...
77+
exist(fullfile(otelcolroot,otelcolname + "-contrib" + otelcol_exe_ext),"file"))
78+
% download and install
7579
otelcol_tar = gunzip(fullfile(otelcol_url, otelcol_zipfilename + ".tar.gz"), otelcolroot);
7680
otelcol_tar = otelcol_tar{1}; % should have only extracted 1 tar file
7781
untar(otelcol_tar, otelcolroot);
7882
delete(otelcol_tar);
7983
end
8084
end
85+
% check for contrib version
86+
if exist(fullfile(otelcolroot,otelcolname + "-contrib" + otelcol_exe_ext),"file")
87+
testCase.OtelcolName = otelcolname + "-contrib";
88+
else
89+
testCase.OtelcolName = otelcolname;
90+
end
8191

8292
testCase.Otelcol = fullfile(otelcolroot, testCase.OtelcolName);
8393

0 commit comments

Comments
 (0)