Skip to content

Commit

Permalink
Merge pull request SigNoz#3801 from SigNoz/release/v0.32.1
Browse files Browse the repository at this point in the history
Release/v0.32.1
  • Loading branch information
prashant-shahi authored Oct 25, 2023
2 parents f12abfb + 720a735 commit 9bad663
Show file tree
Hide file tree
Showing 19 changed files with 569 additions and 113 deletions.
10 changes: 5 additions & 5 deletions deploy/docker-swarm/clickhouse-setup/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ services:
condition: on-failure

query-service:
image: signoz/query-service:0.32.0
image: signoz/query-service:0.32.1
command:
[
"-config=/root/config/prometheus.yml",
Expand Down Expand Up @@ -186,7 +186,7 @@ services:
<<: *db-depend

frontend:
image: signoz/frontend:0.32.0
image: signoz/frontend:0.32.1
deploy:
restart_policy:
condition: on-failure
Expand All @@ -199,7 +199,7 @@ services:
- ../common/nginx-config.conf:/etc/nginx/conf.d/default.conf

otel-collector:
image: signoz/signoz-otel-collector:0.79.11
image: signoz/signoz-otel-collector:0.79.12
command:
[
"--config=/etc/otel-collector-config.yaml",
Expand Down Expand Up @@ -237,7 +237,7 @@ services:
- query-service

otel-collector-migrator:
image: signoz/signoz-schema-migrator:0.79.11
image: signoz/signoz-schema-migrator:0.79.12
deploy:
restart_policy:
condition: on-failure
Expand All @@ -250,7 +250,7 @@ services:
# - clickhouse-3

otel-collector-metrics:
image: signoz/signoz-otel-collector:0.79.11
image: signoz/signoz-otel-collector:0.79.12
command:
[
"--config=/etc/otel-collector-metrics-config.yaml",
Expand Down
6 changes: 3 additions & 3 deletions deploy/docker/clickhouse-setup/docker-compose-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ services:
- --storage.path=/data

otel-collector-migrator:
image: signoz/signoz-schema-migrator:${OTELCOL_TAG:-0.79.11}
image: signoz/signoz-schema-migrator:${OTELCOL_TAG:-0.79.12}
container_name: otel-migrator
command:
- "--dsn=tcp://clickhouse:9000"
Expand All @@ -81,7 +81,7 @@ services:
# Notes for Maintainers/Contributors who will change Line Numbers of Frontend & Query-Section. Please Update Line Numbers in `./scripts/commentLinesForSetup.sh` & `./CONTRIBUTING.md`
otel-collector:
container_name: signoz-otel-collector
image: signoz/signoz-otel-collector:0.79.11
image: signoz/signoz-otel-collector:0.79.12
command:
[
"--config=/etc/otel-collector-config.yaml",
Expand Down Expand Up @@ -118,7 +118,7 @@ services:

otel-collector-metrics:
container_name: signoz-otel-collector-metrics
image: signoz/signoz-otel-collector:0.79.11
image: signoz/signoz-otel-collector:0.79.12
command:
[
"--config=/etc/otel-collector-metrics-config.yaml",
Expand Down
10 changes: 5 additions & 5 deletions deploy/docker/clickhouse-setup/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ services:
# Notes for Maintainers/Contributors who will change Line Numbers of Frontend & Query-Section. Please Update Line Numbers in `./scripts/commentLinesForSetup.sh` & `./CONTRIBUTING.md`

query-service:
image: signoz/query-service:${DOCKER_TAG:-0.32.0}
image: signoz/query-service:${DOCKER_TAG:-0.32.1}
container_name: signoz-query-service
command:
[
Expand Down Expand Up @@ -203,7 +203,7 @@ services:
<<: *db-depend

frontend:
image: signoz/frontend:${DOCKER_TAG:-0.32.0}
image: signoz/frontend:${DOCKER_TAG:-0.32.1}
container_name: signoz-frontend
restart: on-failure
depends_on:
Expand All @@ -215,7 +215,7 @@ services:
- ../common/nginx-config.conf:/etc/nginx/conf.d/default.conf

otel-collector-migrator:
image: signoz/signoz-schema-migrator:${OTELCOL_TAG:-0.79.11}
image: signoz/signoz-schema-migrator:${OTELCOL_TAG:-0.79.12}
container_name: otel-migrator
command:
- "--dsn=tcp://clickhouse:9000"
Expand All @@ -229,7 +229,7 @@ services:


otel-collector:
image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.79.11}
image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.79.12}
container_name: signoz-otel-collector
command:
[
Expand Down Expand Up @@ -269,7 +269,7 @@ services:
condition: service_healthy

otel-collector-metrics:
image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.79.11}
image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.79.12}
container_name: signoz-otel-collector-metrics
command:
[
Expand Down
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"@types/react-resizable": "3.0.3",
"@types/react-router-dom": "^5.1.6",
"@types/react-syntax-highlighter": "15.5.7",
"@types/redux-mock-store": "1.0.4",
"@types/styled-components": "^5.1.4",
"@types/uuid": "^8.3.1",
"@types/webpack": "^5.28.0",
Expand Down Expand Up @@ -192,6 +193,7 @@
"react-hooks-testing-library": "0.6.0",
"react-hot-loader": "^4.13.0",
"react-resizable": "3.0.4",
"redux-mock-store": "1.5.4",
"sass": "1.66.1",
"sass-loader": "13.3.2",
"ts-jest": "^27.1.5",
Expand Down
193 changes: 193 additions & 0 deletions frontend/src/container/BillingContainer/BillingContainer.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
import { billingSuccessResponse } from 'mocks-server/__mockdata__/billing';
import {
notOfTrailResponse,
trialConvertedToSubscriptionResponse,
} from 'mocks-server/__mockdata__/licenses';
import { server } from 'mocks-server/server';
import { rest } from 'msw';
import { act, render, screen } from 'tests/test-utils';
import { getFormattedDate } from 'utils/timeUtils';

import BillingContainer from './BillingContainer';

const lisenceUrl = 'http://localhost/api/v2/licenses';

describe('BillingContainer', () => {
test('Component should render', async () => {
act(() => {
render(<BillingContainer />);
});
const unit = screen.getAllByText(/unit/i);
expect(unit[1]).toBeInTheDocument();
const dataInjection = screen.getByRole('columnheader', {
name: /data ingested/i,
});
expect(dataInjection).toBeInTheDocument();
const pricePerUnit = screen.getByRole('columnheader', {
name: /price per unit/i,
});
expect(pricePerUnit).toBeInTheDocument();
const cost = screen.getByRole('columnheader', {
name: /cost \(billing period to date\)/i,
});
expect(cost).toBeInTheDocument();

const total = screen.getByRole('cell', {
name: /total/i,
});
expect(total).toBeInTheDocument();

const manageBilling = screen.getByRole('button', {
name: /manage billing/i,
});
expect(manageBilling).toBeInTheDocument();

const dollar = screen.getByRole('cell', {
name: /\$0/i,
});
expect(dollar).toBeInTheDocument();

const currentBill = screen.getByRole('heading', {
name: /current bill total/i,
});
expect(currentBill).toBeInTheDocument();
});

test('OnTrail', async () => {
act(() => {
render(<BillingContainer />);
});

const freeTrailText = await screen.findByText('Free Trial');
expect(freeTrailText).toBeInTheDocument();

const currentBill = await screen.findByRole('heading', {
name: /current bill total/i,
});
expect(currentBill).toBeInTheDocument();

const dollar0 = await screen.findByText(/\$0/i);
expect(dollar0).toBeInTheDocument();
const onTrail = await screen.findByText(
/You are in free trial period. Your free trial will end on 20 Oct 2023/i,
);
expect(onTrail).toBeInTheDocument();

const numberOfDayRemaining = await screen.findByText(
/1 days remaining in your billing period./i,
);
expect(numberOfDayRemaining).toBeInTheDocument();
const upgradeButton = await screen.findAllByRole('button', {
name: /upgrade/i,
});
expect(upgradeButton[1]).toBeInTheDocument();
expect(upgradeButton.length).toBe(2);
const checkPaidPlan = await screen.findByText(
/Check out features in paid plans/i,
);
expect(checkPaidPlan).toBeInTheDocument();

const link = screen.getByRole('link', { name: /here/i });
expect(link).toBeInTheDocument();
});

test('OnTrail but trialConvertedToSubscription', async () => {
server.use(
rest.get(lisenceUrl, (req, res, ctx) =>
res(ctx.status(200), ctx.json(trialConvertedToSubscriptionResponse)),
),
);

act(() => {
render(<BillingContainer />);
});

const currentBill = await screen.findByRole('heading', {
name: /current bill total/i,
});
expect(currentBill).toBeInTheDocument();

const dollar0 = await screen.findByText(/\$0/i);
expect(dollar0).toBeInTheDocument();

const onTrail = await screen.findByText(
/You are in free trial period. Your free trial will end on 20 Oct 2023/i,
);
expect(onTrail).toBeInTheDocument();

const receivedCardDetails = await screen.findByText(
/We have received your card details, your billing will only start after the end of your free trial period./i,
);
expect(receivedCardDetails).toBeInTheDocument();

const manageBillingButton = await screen.findByRole('button', {
name: /manage billing/i,
});
expect(manageBillingButton).toBeInTheDocument();

const dayRemainingInBillingPeriod = await screen.findByText(
/1 days remaining in your billing period./i,
);
expect(dayRemainingInBillingPeriod).toBeInTheDocument();
});

test('Not on ontrail', async () => {
server.use(
rest.get(lisenceUrl, (req, res, ctx) =>
res(ctx.status(200), ctx.json(notOfTrailResponse)),
),
);
render(<BillingContainer />);

const billingPeriodText = `Your current billing period is from ${getFormattedDate(
billingSuccessResponse.data.billingPeriodStart,
)} to ${getFormattedDate(billingSuccessResponse.data.billingPeriodEnd)}`;

const billingPeriod = await screen.findByRole('heading', {
name: new RegExp(billingPeriodText, 'i'),
});
expect(billingPeriod).toBeInTheDocument();

const currentBill = await screen.findByRole('heading', {
name: /current bill total/i,
});
expect(currentBill).toBeInTheDocument();

const dollar0 = await screen.findAllByText(/\$1278.3/i);
expect(dollar0[0]).toBeInTheDocument();
expect(dollar0.length).toBe(2);

const metricsRow = await screen.findByRole('row', {
name: /metrics Million 4012 0.1 \$ 401.2/i,
});
expect(metricsRow).toBeInTheDocument();

const logRow = await screen.findByRole('row', {
name: /Logs GB 497 0.4 \$ 198.8/i,
});
expect(logRow).toBeInTheDocument();

const totalBill = await screen.findByRole('cell', {
name: /\$1278/i,
});
expect(totalBill).toBeInTheDocument();

const totalBillRow = await screen.findByRole('row', {
name: /total \$1278/i,
});
expect(totalBillRow).toBeInTheDocument();
});

test('Should render corrent day remaining in billing period', async () => {
server.use(
rest.get(lisenceUrl, (req, res, ctx) =>
res(ctx.status(200), ctx.json(notOfTrailResponse)),
),
);
render(<BillingContainer />);
const dayRemainingInBillingPeriod = await screen.findByText(
/11 days remaining in your billing period./i,
);
expect(dayRemainingInBillingPeriod).toBeInTheDocument();
});
});
15 changes: 1 addition & 14 deletions frontend/src/container/BillingContainer/BillingContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ErrorResponse, SuccessResponse } from 'types/api';
import { CheckoutSuccessPayloadProps } from 'types/api/billing/checkout';
import { License } from 'types/api/licenses/def';
import AppReducer from 'types/reducer/app';
import { getFormattedDate } from 'utils/timeUtils';
import { getFormattedDate, getRemainingDays } from 'utils/timeUtils';

interface DataType {
key: string;
Expand Down Expand Up @@ -98,19 +98,6 @@ const dummyColumns: ColumnsType<DataType> = [
},
];

export const getRemainingDays = (billingEndDate: number): number => {
// Convert Epoch timestamps to Date objects
const startDate = new Date(); // Convert seconds to milliseconds
const endDate = new Date(billingEndDate * 1000); // Convert seconds to milliseconds

// Calculate the time difference in milliseconds
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const timeDifference = endDate - startDate;

return Math.ceil(timeDifference / (1000 * 60 * 60 * 24));
};

export default function BillingContainer(): JSX.Element {
const daysRemainingStr = 'days remaining in your billing period.';
const [headerText, setHeaderText] = useState('');
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/container/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { Button, Divider, MenuProps, Space, Typography } from 'antd';
import { Logout } from 'api/utils';
import ROUTES from 'constants/routes';
import { getRemainingDays } from 'container/BillingContainer/BillingContainer';
import Config from 'container/ConfigDropdown';
import { useIsDarkMode, useThemeMode } from 'hooks/useDarkMode';
import useLicense, { LICENSE_PLAN_STATUS } from 'hooks/useLicense';
Expand All @@ -26,7 +25,7 @@ import { useSelector } from 'react-redux';
import { NavLink } from 'react-router-dom';
import { AppState } from 'store/reducers';
import AppReducer from 'types/reducer/app';
import { getFormattedDate } from 'utils/timeUtils';
import { getFormattedDate, getRemainingDays } from 'utils/timeUtils';

import CurrentOrganization from './CurrentOrganization';
import ManageLicense from './ManageLicense';
Expand Down
Loading

0 comments on commit 9bad663

Please sign in to comment.