Skip to content

Commit

Permalink
Merge pull request #1573 from memphisdev/RND-382-ui-for-run-benchmark
Browse files Browse the repository at this point in the history
ui for run benchmark
  • Loading branch information
SvetaMemphis authored Jan 1, 2024
2 parents 4b032d8 + c7fcd2c commit e640fcf
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 8 deletions.
120 changes: 120 additions & 0 deletions ui_src/src/components/runBenchmarkModal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright 2022-2023 The Memphis.dev Authors
// Licensed under the Memphis Business Source License 1.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// Changed License: [Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0), as published by the Apache Foundation.
//
// https://github.com/memphisdev/memphis/blob/master/LICENSE
//
// Additional Use Grant: You may make use of the Licensed Work (i) only as part of your own product or service, provided it is not a message broker or a message queue product or service; and (ii) provided that you do not use, provide, distribute, or make available the Licensed Work as a Service.
// A "Service" is a commercial offering, product, hosted, or managed service, that allows third parties (other than your own employees and contractors acting on your behalf) to access and/or use the Licensed Work or a substantial set of the features or functionality of the Licensed Work to third parties as a software-as-a-service, platform-as-a-service, infrastructure-as-a-service or other similar services that compete with Licensor products or services.

import './style.scss';

import React, { useEffect, useState } from 'react';
import Modal from '../modal';
import { IoRocket } from 'react-icons/io5';
import Copy from '../copy';
import CustomTabs from '../Tabs';
import { githubUrls } from '../../const/globalConst';
import { SiLinux, SiApple, SiWindows11 } from 'react-icons/si';
import { LOCAL_STORAGE_BROKER_HOST, LOCAL_STORAGE_ENV, LOCAL_STORAGE_ACCOUNT_ID } from '../../const/localStorageConsts';

let write =
'mem bench producer --message-size 128 --count 1000 --concurrency 1 --host <host> --account-id <account-id(not needed for open-source)> --user <client type user> --password <password>';
let read =
'mem bench consumer --message-size 128 --count 1000 --concurrency 1 --batch-size 50 --host <host> --account-id <account-id(not needed for open-source)> --user <client type user> --password <password>';

const RunBenchmarkModal = ({ open, clickOutside }) => {
const [tabValue, setTabValue] = useState('Windows');
const [writeLink, setWriteLink] = useState(null);
const [readLink, setReadLink] = useState(null);

useEffect(() => {
let host =
localStorage.getItem(LOCAL_STORAGE_ENV) === 'docker'
? 'localhost'
: localStorage.getItem(LOCAL_STORAGE_BROKER_HOST)
? localStorage.getItem(LOCAL_STORAGE_BROKER_HOST)
: 'memphis.memphis.svc.cluster.local';
write = write.replace('<host>', host);
write = write.replace('<account-id(not needed for open-source)>', parseInt(localStorage.getItem(LOCAL_STORAGE_ACCOUNT_ID)));
read = write.replace('<host>', host);
read = write.replace('<account-id(not needed for open-source)>', parseInt(localStorage.getItem(LOCAL_STORAGE_ACCOUNT_ID)));
setWriteLink(write);
setReadLink(read);
}, []);

return (
<Modal
header={
<div className="modal-header connector-modal-header">
<div className="header-img-container">
<IoRocket className="headerImage" alt="stationImg" style={{ color: '#6557FF' }} />
</div>
<div className="connector-modal-title">
<div className="modal-title">Run a benchmark</div>
</div>
</div>
}
className={'modal-wrapper'}
width="550px"
clickOutside={clickOutside}
open={open}
displayButtons={true}
rBtnText={'Close'}
rBtnClick={clickOutside}
>
<div className="benchmark-wrapper">
<CustomTabs
tabs={['Windows', 'Mac', 'Linux RPM', 'Linux APK']}
icons={[<SiWindows11 />, <SiApple />, <SiLinux />, <SiLinux />]}
size={'small'}
tabValue={tabValue}
onChange={(tabValue) => setTabValue(tabValue)}
/>

<>
<p className="action">
<label>Step 1:</label> Install Memphis CLI
</p>
<div className="url-wrapper">
<p className="url-text"> {githubUrls['cli'][tabValue]}</p>
<div className="icon">
<Copy width="18" data={githubUrls['cli'][tabValue]} />
</div>
</div>
<p className="action">
<label>Step 2:</label> For inspecting write latency, run the following
</p>
<div className="url-wrapper">
<p className="url-text">{writeLink}</p>
<div className="icon">
<Copy width="18" data={writeLink || write} />
</div>
</div>
<p className="action">
<label>Step 3:</label> For inspecting read latency, run the following
</p>
<div className="url-wrapper">
<p className="url-text">{readLink || read}</p>
<div className="icon">
<Copy width="18" data={readLink || read} />
</div>
</div>
</>

<span>
<p className="subtitle">Considerations to keep in mind:</p>
<p className="subtitle">1. The latency and throughput largely depend on the internet connection.</p>
<p className="subtitle">
2.These figures are preliminary and subject to improvement if necessary. Consult with an engineer for further optimization.
</p>
</span>
</div>
</Modal>
);
};

export default RunBenchmarkModal;
85 changes: 85 additions & 0 deletions ui_src/src/components/runBenchmarkModal/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
.benchmark-wrapper {
width: 100%;
height: 100%;
.title {
color: #101828;
font-family: 'InterSemiBold';
font-size: 18px;
line-height: 28px;
margin-bottom: 5px;
}
.subtitle {
color: #475467;
font-family: 'Inter';
font-size: 14px;
line-height: 25px;
margin-bottom: 5px;
p {
margin: 0px;
}
}
.secondary-text {
color: #bcbcbc;
font-family: 'Inter';
font-size: 12px;
line-height: 20px;
}
.url-wrapper {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding-left: 13px;
height: 40px;
border-radius: 4px;
border: 1px solid #e7e7e7;
margin-bottom: 15px;
.url-text {
margin: 0px;
color: #737373;
font-family: 'InterMedium';
font-size: 14px;
line-height: 20px;
overflow-x: auto;
white-space: nowrap;
max-width: 430px;
height: 100%;
display: flex;
align-items: center;
}

.icon {
height: 33px;
width: 37px;
display: flex;
align-items: center;
justify-content: center;
background: #fbfbfb;
border-left: 1px solid #e7e7e7;
border-top-right-radius: inherit;
border-bottom-right-radius: inherit;
cursor: pointer;
}
}
.action {
font-size: 14px;
font-family: 'InterMedium';
margin: 5px 0px;
label {
color: var(--purple);
font-weight: 600;
margin-right: 5px;
}
}

.ant-tabs-tab .tabs-name {
font-size: 12px;
}
.ant-tabs-tab + .ant-tabs-tab {
margin: 0 0 0 15px;
}
.ant-tabs-tab {
font-size: 12px;
padding: 8px 0px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { BiLogoGoLang, BiLogoPython } from 'react-icons/bi';
import { SiDotnet } from 'react-icons/si';
import { DiJavascript1 } from 'react-icons/di';
import ConnectorInfo from '../../../../components/connectorInfo';
import RunBenchmarkModal from '../../../../components/runBenchmarkModal';

const overlayStylesConnectors = {
borderRadius: '8px',
Expand Down Expand Up @@ -81,6 +82,7 @@ const ProduceConsumList = ({ producer }) => {
const [connectorsSinkList, setConnectorsSinkList] = useState([]);
const [cgsList, setCgsList] = useState([]);
const [openProduceMessages, setOpenProduceMessages] = useState(false);
const [openRunBenchmark, setOpenRunBenchmark] = useState(false);
const [cgDetails, setCgDetails] = useState([]);
const [openCreateProducer, setOpenCreateProducer] = useState(false);
const [openCreateConsumer, setOpenCreateConsumer] = useState(false);
Expand All @@ -100,14 +102,14 @@ const ProduceConsumList = ({ producer }) => {
const [loading, setLoader] = useState(false);
const producerItemsList = [
{
action: 'Produce Synthetic Data',
action: 'Produce synthetic data',
onClick: () => {
setOpenProduceMessages(true);
setOpenProducerPopover(false);
}
},
{
action: 'Develop a Producer',
action: 'Develop a producer',
onClick: () => {
setOpenCreateProducer(true);
setOpenProducerPopover(false);
Expand All @@ -121,7 +123,14 @@ const ProduceConsumList = ({ producer }) => {
}
},
{
action: 'Add a Source',
action: 'Run benchmark',
onClick: () => {
setOpenRunBenchmark(true);
setOpenProducerPopover(false);
}
},
{
action: 'Add a source',
onClick: () => {
setOpenConnectorModal(true);
setOpenProducerPopover(false);
Expand All @@ -131,7 +140,7 @@ const ProduceConsumList = ({ producer }) => {

const consumeItemsList = [
{
action: 'Develop a Consumer',
action: 'Develop a consumer',
onClick: () => {
setOpenCreateConsumer(true);
setOpenProducerPopover(false);
Expand All @@ -145,7 +154,14 @@ const ProduceConsumList = ({ producer }) => {
}
},
{
action: 'Add a Sink',
action: 'Run benchmark',
onClick: () => {
setOpenRunBenchmark(true);
setOpenProducerPopover(false);
}
},
{
action: 'Add a sink',
onClick: () => {
setOpenConnectorModal(true);
setOpenProducerPopover(false);
Expand Down Expand Up @@ -393,7 +409,7 @@ const ProduceConsumList = ({ producer }) => {
<p className="title">
<TooltipComponent text="max allowed producers" placement="right">
<>
Sources ({(producersList?.length > 0 && countProducers(producersList).toLocaleString()) || 0}
Producers ({(producersList?.length > 0 && countProducers(producersList).toLocaleString()) || 0}
{isCloud() && '/' + stationState?.stationSocketData?.max_amount_of_allowed_producers?.toLocaleString()})
</>
</TooltipComponent>
Expand Down Expand Up @@ -744,8 +760,7 @@ const ProduceConsumList = ({ producer }) => {
<div className="header-img-container">
<PlayVideoIcon className="headerImage" alt="stationImg" />
</div>
<p>Produce a message</p>
<label>Produce a message through the Console.</label>
<p>Produce synthetic data</p>
</div>
}
className={'modal-wrapper produce-modal'}
Expand Down Expand Up @@ -832,6 +847,7 @@ const ProduceConsumList = ({ producer }) => {
</Modal>
<ConnectorError open={openConnectorError} clickOutside={() => setOpenConnectorError(false)} connectorId={selectedConnector?.id} />
<ConnectorInfo open={openConnectorInfo} clickOutside={() => setOpenConnectorInfo(false)} connectorId={selectedConnector?.id} />
<RunBenchmarkModal open={openRunBenchmark} clickOutside={() => setOpenRunBenchmark(false)} />
</div>
);
};
Expand Down

0 comments on commit e640fcf

Please sign in to comment.