Skip to content

Commit

Permalink
Merge pull request #191 from splitio/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
mmelograno authored Dec 20, 2024
2 parents bbc5240 + 1cd9b24 commit 9f07145
Show file tree
Hide file tree
Showing 32 changed files with 1,368 additions and 3,752 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: echo "BUILD_VERSION=$(cat package.json | grep version | head -1 | awk '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')" >> $GITHUB_ENV

- name: Docker build
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name == 'push' }}
Expand All @@ -59,7 +59,7 @@ jobs:
run: echo "BUILD_VERSION=$(cat package.json | grep version | head -1 | awk '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')" >> $GITHUB_ENV

- name: Docker build
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
push: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Docker Build
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
push: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-license-year.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
git commit -m "Updated License Year" -a
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Update License Year
Expand Down
5 changes: 2 additions & 3 deletions .jest/app.setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { gracefulShutDown } = require('../utils/testWrapper/index');

afterAll( async (done) => {
afterAll(async () => {
await gracefulShutDown();
done()
})
})
7 changes: 6 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
2.7.0 (Dec 20, 2024)
- Added support to arm64 images.
- Updated base image to node:20.13.1-alpine3.20
- Updated @splitsoftware/splitio package to version 11.0.3 that includes vulnerability fixes and other improvements.

2.6.0 (May 16, 2024)
- Updated @splitsoftware/splitio package to version 10.26.0 that includes:
- Added support for targeting rules based on semantic versions (https://semver.org/).
- Added special impression label "targeting rule type unsupported by sdk" when the matcher type is not supported by the SDK, which returns 'control' treatment.
- Updated Split API client to include the flags spec version query parameter for the `splitChanges` and `auth` endpoints.
- Updated base image to node:20.13.1-alpine3.19
- Updated base image to node:20.13.1-alpine3.19

2.5.1 (Mar 14, 2024)
- Updated @splitsoftware/splitio package to version 10.25.1 that includes:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Builder stage
FROM node:20.13.1-alpine3.19 AS builder
FROM node:20.13.1-alpine3.20 AS builder

WORKDIR /usr/src/split-evaluator

Expand All @@ -8,7 +8,7 @@ COPY package.json package-lock.json ./
RUN npm install --only=production

# Runner stage
FROM node:20.13.1-alpine3.19 AS runner
FROM node:20.13.1-alpine3.20 AS runner

WORKDIR /usr/src/split-evaluator

Expand Down
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Setup defaults
MAKE ?= make
DOCKER ?= docker
PLATFORM ?= linux/arm64/v8,linux/amd64
BUILDER ?= container

version := $(shell cat package.json | grep '"version": "' | sed 's/ "version": "//' | tr -d '",')

# Help target borrowed from: https://docs.cloudposse.com/reference/best-practices/make-best-practices/
## This help screen
help:
@printf "Available targets:\n\n"
@awk '/^[a-zA-Z\-\_0-9%:\\]+/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = $$1; \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
gsub("\\\\", "", helpCommand); \
gsub(":+$$", "", helpCommand); \
printf " \x1b[32;01m%-35s\x1b[0m %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST) | sort -u
@printf "\n"

## Build release-ready docker images with proper tags and output push commands in stdout
images_release_multi_load: # entrypoints
@echo "make sure you have buildx configured 'docker buildx ls', if not 'docker buildx create --name container --driver=docker-container'"
$(DOCKER) buildx build \
-t splitsoftware/split-evaluator:latest -t splitsoftware/split-evaluator:$(version) \
--platform $(PLATFORM) \
--builder $(BUILDER) \
--load .
@echo "Images created. Make sure everything works ok, and then run the following commands to push them."
@echo "$(DOCKER) push splitsoftware/split-evaluator:$(version)"
@echo "$(DOCKER) push splitsoftware/split-evaluator:latest"

platform_str = $(if $(PLATFORM),--platform $(PLATFORM),)
builder_str = $(if $(BUILDER),--builder $(BUILDER),)
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,24 @@ Split has built and maintains SDKs for:

* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
* Javascript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
* JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
* JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
* Node.js [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
* PHP thin-client [Github](https://github.com/splitio/php-thin-client) [Docs](https://help.split.io/hc/en-us/articles/18305128673933-PHP-Thin-Client-SDK)
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
* React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
* React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
* Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK)
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)

For a comprehensive list of opensource projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).

**Learn more about Split:**

Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [docs.split.io](https://help.split.io/hc/en-us) for more detailed information.
Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](https://help.split.io) for more detailed information.
9 changes: 3 additions & 6 deletions admin/__tests__/healthcheck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,23 @@ const { expectError } = require('../../utils/testWrapper/index');

describe('healthcheck', () => {
// Testing authorization
test('should be 401 if auth is not passed', async (done) => {
test('should be 401 if auth is not passed', async () => {
const response = await request(app)
.get('/admin/healthcheck');
expectError(response, 401, 'Unauthorized');
done();
});

test('should be 401 if auth does not match', async (done) => {
test('should be 401 if auth does not match', async () => {
const response = await request(app)
.get('/admin/healthcheck')
.set('Authorization', 'invalid');
expectError(response, 401, 'Unauthorized');
done();
});

test('should be 200', async (done) => {
test('should be 200', async () => {
const response = await request(app)
.get('/admin/healthcheck')
.set('Authorization', 'test');
expect(response.statusCode).toEqual(200);
done();
});
});
11 changes: 4 additions & 7 deletions admin/__tests__/machine.test.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
const os = require('os');
const ip = require('@splitsoftware/splitio/lib/utils/ip');
const ip = require('@splitsoftware/splitio/cjs/utils/ip');
const request = require('supertest');
const app = require('../../app');
const { expectError } = require('../../utils/testWrapper/index');

describe('machine', () => {
// Testing authorization
test('should be 401 if auth is not passed', async (done) => {
test('should be 401 if auth is not passed', async () => {
const response = await request(app)
.get('/admin/machine');
expectError(response, 401, 'Unauthorized');
done();
});

test('should be 401 if auth does not match', async (done) => {
test('should be 401 if auth does not match', async () => {
const response = await request(app)
.get('/admin/machine')
.set('Authorization', 'invalid');
expectError(response, 401, 'Unauthorized');
done();
});

test('should be 200', async (done) => {
test('should be 200', async () => {
const response = await request(app)
.get('/admin/machine')
.set('Authorization', 'test');
expect(response.statusCode).toEqual(200);
expect(response.body).toHaveProperty('ip', ip.address());
expect(response.body).toHaveProperty('name', os.hostname());
done();
});
});
9 changes: 3 additions & 6 deletions admin/__tests__/ping.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,23 @@ const { expectError } = require('../../utils/testWrapper/index');

describe('ping', () => {
// Testing authorization
test('should be 401 if auth is not passed', async (done) => {
test('should be 401 if auth is not passed', async () => {
const response = await request(app)
.get('/admin/ping');
expectError(response, 401, 'Unauthorized');
done();
});

test('should be 401 if auth does not match', async (done) => {
test('should be 401 if auth does not match', async () => {
const response = await request(app)
.get('/admin/ping')
.set('Authorization', 'invalid');
expectError(response, 401, 'Unauthorized');
done();
});

test('should be 200', async (done) => {
test('should be 200', async () => {
const response = await request(app)
.get('/admin/ping')
.set('Authorization', 'test');
expect(response.statusCode).toBe(200);
done();
});
});
42 changes: 18 additions & 24 deletions admin/__tests__/stats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { apiKeyMocksMap } = require('../../utils/mocks');

jest.mock('node-fetch', () => {
return jest.fn().mockImplementation(() => {
return Promise.reject({ response: { status: 404, response: 'response'}});
return Promise.reject({ response: { status: 404, response: 'response' } });
});
});
describe('stats', () => {
Expand All @@ -26,24 +26,22 @@ describe('stats', () => {
const environments = JSON.parse(process.env.SPLIT_EVALUATOR_ENVIRONMENTS);

// Testing authorization
test('should be 401 if auth is not passed', async (done) => {
test('should be 401 if auth is not passed', async () => {
const app = require('../../app');
const response = await request(app)
.get('/admin/stats');
expectError(response, 401, 'Unauthorized');
done();
});

test('should be 401 if auth does not match', async (done) => {
test('should be 401 if auth does not match', async () => {
const app = require('../../app');
const response = await request(app)
.get('/admin/stats')
.set('Authorization', 'invalid');
expectError(response, 401, 'Unauthorized');
done();
});

test('uptime and healthcheck', async (done) => {
test('uptime and healthcheck', async () => {
const app = require('../../app');
const version = utils.getVersion();
const environmentManager = require('../../environmentManager').getInstance();
Expand All @@ -62,11 +60,9 @@ describe('stats', () => {
sdk: sdkLanguage,
sdkVersion: sdkVersion,
});

done();
});

test('ready environment stats', async (done) => {
test('ready environment stats', async () => {
const environmentManager = require('../../environmentManager').getInstance();
const app = require('../../app');
const response = await request(app)
Expand All @@ -89,10 +85,9 @@ describe('stats', () => {
impressionsMode: 'OPTIMIZED',
});
});
done();
});

test('stats for two environments where one is timed out', async (done) => {
test('stats for two environments where one is timed out', async () => {
// Environment configurations
const environmentsConfig = [
{ API_KEY: 'test1', AUTH_TOKEN: 'timedout' },
Expand Down Expand Up @@ -142,19 +137,18 @@ describe('stats', () => {
});
response = await request(app)
.get('/client/get-treatment?key=test&split-name=testing_split_blue')
.set('Authorization', 'key_blue')
.then(async () => {
expect(response.statusCode).toEqual(200);
response = await request(app)
.get('/admin/stats')
.set('Authorization', 'key_blue');
expect(response.statusCode).toEqual(200);
stats = response.body;
const lastEvaluation = stats.environments[utils.obfuscate('key_blue')].lastEvaluation;
expect(lastEvaluation).not.toBe(undefined);
expect(lastEvaluation).toBe(environmentManager.getEnvironment('key_blue').lastEvaluation);
done();
});
.set('Authorization', 'key_blue');

expect(response.statusCode).toEqual(200);
response = await request(app)
.get('/admin/stats')
.set('Authorization', 'key_blue');
expect(response.statusCode).toEqual(200);
stats = response.body;
const lastEvaluation = stats.environments[utils.obfuscate('key_blue')].lastEvaluation;
expect(lastEvaluation).not.toBe(undefined);
expect(lastEvaluation).toBe(environmentManager.getEnvironment('key_blue').lastEvaluation);

});
});
});
9 changes: 3 additions & 6 deletions admin/__tests__/uptime.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,23 @@ const { expectError } = require('../../utils/testWrapper/index');

describe('uptime', () => {
// Testing authorization
test('should be 401 if auth is not passed', async (done) => {
test('should be 401 if auth is not passed', async () => {
const response = await request(app)
.get('/admin/uptime');
expectError(response, 401, 'Unauthorized');
done();
});

test('should be 401 if auth does not match', async (done) => {
test('should be 401 if auth does not match', async () => {
const response = await request(app)
.get('/admin/uptime')
.set('Authorization', 'invalid');
expectError(response, 401, 'Unauthorized');
done();
});

test('should be 200', async (done) => {
test('should be 200', async () => {
const response = await request(app)
.get('/admin/uptime')
.set('Authorization', 'test');
expect(response.statusCode).toBe(200);
done();
});
});
Loading

0 comments on commit 9f07145

Please sign in to comment.