Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@ harnic-spa/build

npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*
/demo/jenkins-data/
44 changes: 44 additions & 0 deletions Dockerfile.demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM node:14 as frontend

WORKDIR /app

COPY harnic-spa harnic-spa
WORKDIR /app/harnic-spa

RUN npm install
RUN npm run build


FROM jenkins/jenkins

USER root

RUN apt update && apt install -y build-essential python3 sudo python3-pip mc psmisc procps jq
RUN usermod -aG sudo jenkins && sed -i s/[!]// /etc/shadow
# RUN echo "#! /usr/bin/sudo /bin/sh\n/usr/bin/docker \"\$@\"" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker
# RUN echo "PATH=\$PATH:\$HOME/.local/bin" >> /etc/profile
# RUN jenkins-plugin-cli --verbose --plugins ws-cleanup git dashboard-view htmlpublisher locale plot

# env var to tell the version
ENV IMG_LABEL="-image_label-"

# set the working directory in the container
WORKDIR /app

# copy the dependencies file to the working directory
COPY --from=frontend /app/harnic-spa harnic-spa
ENV SPA_LOCATION=/app/harnic-spa

# install dependencies
COPY requirements.txt .
RUN pip3 install -r requirements.txt

# install backend
COPY harnic harnic
COPY setup.py .

RUN pip3 install -e .

WORKDIR /
ENV JAVA_OPTS='-Dhudson.model.DirectoryBrowserSupport.CSP=""'
USER jenkins
43 changes: 43 additions & 0 deletions demo/jenkins-data/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version='1.1' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors>
<string>jenkins.diagnostics.ControllerExecutorsNoAgents</string>
<string>jenkins.diagnostics.SecurityIsOffMonitor</string>
<string>jenkins.security.ResourceDomainRecommendation</string>
</disabledAdministrativeMonitors>
<version>2.312</version>
<numExecutors>1</numExecutors>
<mode>NORMAL</mode>
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
<securityRealm class="hudson.security.SecurityRealm$None"/>
<disableRememberMe>false</disableRememberMe>
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
<workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}</workspaceDir>
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
<markupFormatter class="hudson.markup.EscapedMarkupFormatter"/>
<jdks/>
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
<clouds/>
<quietPeriod>0</quietPeriod>
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
<views>
<hudson.model.AllView>
<owner class="hudson" reference="../../.."/>
<name>all</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
</views>
<primaryView>all</primaryView>
<slaveAgentPort>50000</slaveAgentPort>
<label></label>
<crumbIssuer class="hudson.security.csrf.DefaultCrumbIssuer">
<excludeClientIPFromCrumb>false</excludeClientIPFromCrumb>
</crumbIssuer>
<nodeProperties/>
<globalNodeProperties/>
<nodeRenameMigrationNeeded>false</nodeRenameMigrationNeeded>
</hudson>
248 changes: 248 additions & 0 deletions demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
<?xml version='1.1' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<jenkins.model.BuildDiscarderProperty>
<strategy class="hudson.tasks.LogRotator">
<daysToKeep>-1</daysToKeep>
<numToKeep>25</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</strategy>
</jenkins.model.BuildDiscarderProperty>
<com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.32">
<autoRebuild>false</autoRebuild>
<rebuildDisabled>false</rebuildDisabled>
</com.sonyericsson.rebuild.RebuildSettings>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition plugin="git-parameter@0.9.13">
<name>BRANCH</name>
<uuid>c7a81730-de40-4eef-907c-b271fcf7a5c5</uuid>
<type>PT_BRANCH</type>
<branch></branch>
<tagFilter>*</tagFilter>
<branchFilter>.*</branchFilter>
<sortMode>NONE</sortMode>
<defaultValue>origin/main</defaultValue>
<selectedValue>NONE</selectedValue>
<quickFilterEnabled>false</quickFilterEnabled>
<listSize>5</listSize>
</net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
<scm class="hudson.plugins.git.GitSCM" plugin="git@4.8.2">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>https://github.com/up9inc/mockintosh.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>${BRANCH}</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="empty-list"/>
<extensions/>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers>
<hudson.triggers.SCMTrigger>
<spec>* * * * *</spec>
<ignorePostCommitHooks>false</ignorePostCommitHooks>
</hudson.triggers.SCMTrigger>
</triggers>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Shell>
<command># PREPARE
killall python3 || echo Not running
pip3 install -r requirements.txt
pip3 install mitmproxy
(PYTHONPATH=.:./tests_integrated python3 -m mockintosh tests_integrated/integration_config.yaml --interceptor=custom_interceptors.intercept_for_logging --interceptor=custom_interceptors.intercept_for_modifying &gt; ./tests_integrated/server.log 2&gt;&amp;1) &amp;
sleep 5
curl -vf http://localhost:8001
curl -vkf https://localhost:8000
mkdir traffic
(~/.local/bin/mitmdump -vvv --mode regular --ssl-insecure --set block-global=false --listen-port 8888 --set hardump=./traffic/captured.har -s $HOME/scripts/har_dump.py &gt; ./traffic/mitmdump.log 2&gt;&amp;1) &amp;
sleep 5
HTTP_PROXY=http://localhost:8888 curl -vf http://localhost:8001
HTTPS_PROXY=http://localhost:8888 curl -vkf https://localhost:8000
sed -i s/test_conn_status/_test_conn_status/ tests_integrated/tests_integration.py</command>
<configuredLocalRules/>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command># RUN
export HTTP_PROXY=http://localhost:8888
export HTTPS_PROXY=http://localhost:8888
export NO_PROXY=raw.githubusercontent.com
python3 -m unittest -v tests_integrated.tests_integration.RESTTests</command>
<configuredLocalRules/>
<unstableReturn>1</unstableReturn>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command># POST-PROCESS
killall -SIGUSR1 mitmdump # supposed to trigger HAR write
sleep 5
ls `pwd`/traffic/captured.har # make sure it was written
killall python3 || echo Not running # shut down mockintosh server

mkdir -p $HOME/hars/$GIT_BRANCH/

BASELINE=$HOME/hars/origin/main

if ls $BASELINE/latest.har; then
python3 -m harnic $BASELINE/latest.har traffic/captured.har
cp diff_latest.har_captured.har/kpis.json $HOME/hars/$GIT_BRANCH/
w_reorders=`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.ratio`
woreorders=`cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.ratio`
echo with_reorders,strict_order &gt; kpis.csv
echo `python3 -c &quot;print($w_reorders*100)&quot;`,`python3 -c &quot;print($woreorders*100)&quot;` &gt;&gt; kpis.csv

echo matched,modified,added,removed &gt; entries-r.csv
echo `cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.matched`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.modified`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.added`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.removed` &gt;&gt; entries-r.csv

echo matched,modified,added,removed &gt; entries-n.csv
echo `cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.matched`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.modified`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.added`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.removed` &gt;&gt; entries-n.csv
fi


cp ./traffic/captured.har $HOME/hars/$GIT_BRANCH/latest.har
</command>
<configuredLocalRules/>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.plugins.plot.PlotPublisher plugin="plot@2.1.9">
<plots>
<hudson.plugins.plot.Plot>
<title>Match Score</title>
<description></description>
<yaxis>%</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>kpis.csv</file>
<label></label>
<fileType>csv</fileType>
<inclusionFlag>OFF</inclusionFlag>
<exclusionValues></exclusionValues>
<exclusionValuesList class="java.util.Arrays$ArrayList">
<a class="string-array">
<string></string>
</a>
</exclusionValuesList>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>Traffic Diff Stats</group>
<numBuilds></numBuilds>
<csvFileName>plot-3205114369520422087.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
<keepRecords>false</keepRecords>
<exclZero>false</exclZero>
<logarithmic>false</logarithmic>
<yaxisMinimum>50.0</yaxisMinimum>
<yaxisMaximum></yaxisMaximum>
</hudson.plugins.plot.Plot>
<hudson.plugins.plot.Plot>
<title>Items: With Reorders</title>
<description></description>
<yaxis>number of traffic entries</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>entries-r.csv</file>
<label></label>
<fileType>csv</fileType>
<inclusionFlag>OFF</inclusionFlag>
<exclusionValues></exclusionValues>
<exclusionValuesList class="java.util.Arrays$ArrayList">
<a class="string-array">
<string></string>
</a>
</exclusionValuesList>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>Traffic Diff Stats</group>
<numBuilds></numBuilds>
<csvFileName>plot-7979134032686517538.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
<keepRecords>false</keepRecords>
<exclZero>false</exclZero>
<logarithmic>false</logarithmic>
<yaxisMinimum></yaxisMinimum>
<yaxisMaximum></yaxisMaximum>
</hudson.plugins.plot.Plot>
<hudson.plugins.plot.Plot>
<title>Items: Strict Order</title>
<description></description>
<yaxis>number of traffic entries</yaxis>
<series>
<hudson.plugins.plot.CSVSeries>
<file>entries-n.csv</file>
<label></label>
<fileType>csv</fileType>
<inclusionFlag>OFF</inclusionFlag>
<exclusionValues></exclusionValues>
<exclusionValuesList class="java.util.Arrays$ArrayList">
<a class="string-array">
<string></string>
</a>
</exclusionValuesList>
<url></url>
<displayTableFlag>false</displayTableFlag>
</hudson.plugins.plot.CSVSeries>
</series>
<group>Traffic Diff Stats</group>
<numBuilds></numBuilds>
<csvFileName>plot-2287905576478828014.csv</csvFileName>
<csvLastModification>0</csvLastModification>
<style>line</style>
<useDescr>false</useDescr>
<keepRecords>false</keepRecords>
<exclZero>false</exclZero>
<logarithmic>false</logarithmic>
<yaxisMinimum></yaxisMinimum>
<yaxisMaximum></yaxisMaximum>
</hudson.plugins.plot.Plot>
</plots>
</hudson.plugins.plot.PlotPublisher>
<htmlpublisher.HtmlPublisher plugin="htmlpublisher@1.25">
<reportTargets>
<htmlpublisher.HtmlPublisherTarget>
<reportName>Traffic Comparison Report</reportName>
<reportDir>diff_latest.har_captured.har</reportDir>
<reportFiles>index.html</reportFiles>
<alwaysLinkToLastBuild>true</alwaysLinkToLastBuild>
<reportTitles></reportTitles>
<keepAll>true</keepAll>
<allowMissing>true</allowMissing>
<includes>**/*</includes>
<escapeUnderscores>true</escapeUnderscores>
</htmlpublisher.HtmlPublisherTarget>
</reportTargets>
</htmlpublisher.HtmlPublisher>
</publishers>
<buildWrappers>
<hudson.plugins.ws__cleanup.PreBuildCleanup plugin="ws-cleanup@0.39">
<deleteDirs>false</deleteDirs>
<cleanupParameter></cleanupParameter>
<externalDelete></externalDelete>
<disableDeferredWipeout>false</disableDeferredWipeout>
</hudson.plugins.ws__cleanup.PreBuildCleanup>
</buildWrappers>
</project>
5 changes: 5 additions & 0 deletions demo/jenkins-data/locale.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version='1.1' encoding='UTF-8'?>
<locale plugin="locale@1.4">
<systemLocale>en_US</systemLocale>
<ignoreAcceptLanguage>true</ignoreAcceptLanguage>
</locale>
Loading