Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: support Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
victorb authored and daviddias committed Feb 28, 2018
1 parent 4312513 commit bc66e9f
Show file tree
Hide file tree
Showing 37 changed files with 535 additions and 322 deletions.
1 change: 1 addition & 0 deletions .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const createServer = require('ipfsd-ctl').createServer

const server = createServer()

module.exports = {
karma: {
files: [{
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ node_modules

lib
dist
test/test-data/go-ipfs-repo/LOCK
test/test-data/go-ipfs-repo/LOG
test/test-data/go-ipfs-repo/LOG.old
test/fixtures/go-ipfs-repo/LOCK
test/fixtures/go-ipfs-repo/LOG
test/fixtures/go-ipfs-repo/LOG.old

# while testing npm5
package-lock.json
Expand Down
2 changes: 2 additions & 0 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
javascript()
20 changes: 13 additions & 7 deletions test/cli/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
const expect = require('chai').expect
const clean = require('../utils/clean')
const ipfsCmd = require('../utils/ipfs-exec')
const isWindows = require('../utils/platforms').isWindows
const pull = require('pull-stream')
const toPull = require('stream-to-pull-stream')
const os = require('os')
const path = require('path')
const hat = require('hat')
const fs = require('fs')

const isWindows = os.platform() === 'win32'
const skipOnWindows = isWindows() ? it.skip : it

const checkLock = (repo, cb) => {
// skip on windows
Expand All @@ -28,9 +29,13 @@ const checkLock = (repo, cb) => {
}

function testSignal (ipfs, sig) {
let proc = null
return ipfs('init').then(() => {
proc = ipfs('daemon')
return ipfs('config', 'Addresses', JSON.stringify({
API: '/ip4/127.0.0.1/tcp/0',
Gateway: '/ip4/127.0.0.1/tcp/0'
}), '--json')
}).then(() => {
const proc = ipfs('daemon')
return new Promise((resolve, reject) => {
pull(
toPull(proc.stdout),
Expand Down Expand Up @@ -72,11 +77,12 @@ describe('daemon', () => {

afterEach(() => clean(repoPath))

it('do not crash if Addresses.Swarm is empty', function (done) {
skipOnWindows('do not crash if Addresses.Swarm is empty', function (done) {
this.timeout(100 * 1000)

ipfs('init').then(() => {
return ipfs('config', 'Addresses', JSON.stringify({
Swarm: [],
API: '/ip4/127.0.0.1/tcp/0',
Gateway: '/ip4/127.0.0.1/tcp/0'
}), '--json')
Expand All @@ -85,18 +91,18 @@ describe('daemon', () => {
}).then((res) => {
expect(res).to.have.string('Daemon is ready')
done()
}).catch((err) => done(err))
}).catch(err => done(err))
})

it('should handle SIGINT gracefully', function (done) {
skipOnWindows('should handle SIGINT gracefully', function (done) {
this.timeout(100 * 1000)

testSignal(ipfs, 'SIGINT').then(() => {
checkLock(repoPath, done)
}).catch(done)
})

it('should handle SIGTERM gracefully', function (done) {
skipOnWindows('should handle SIGTERM gracefully', function (done) {
this.timeout(100 * 1000)

testSignal(ipfs, 'SIGTERM').then(() => {
Expand Down
31 changes: 22 additions & 9 deletions test/core/bitswap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ const multihashing = require('multihashing-async')
const CID = require('cids')

const IPFSFactory = require('ipfsd-ctl')
const fDaemon = IPFSFactory.create({ type: 'js' })
const fInProc = IPFSFactory.create({ type: 'proc' })

// This gets replaced by '../utils/create-repo-browser.js' in the browser
const createTempRepo = require('../utils/create-repo-nodejs.js')

const IPFS = require('../../src/core')

// TODO bitswap tests on windows is failing, missing proper shutdown of daemon
// https://github.com/ipfs/js-ipfsd-ctl/pull/205
const isWindows = require('../utils/platforms').isWindows
const skipOnWindows = isWindows() ? describe.skip : describe

function makeBlock (callback) {
const d = Buffer.from(`IPFS is awesome ${Math.random()}`)

Expand Down Expand Up @@ -67,7 +70,7 @@ function connectNodes (remoteNode, inProcNode, callback) {

let nodes = []

function addNode (inProcNode, callback) {
function addNode (fDaemon, inProcNode, callback) {
fDaemon.spawn({
exec: './src/cli/bin.js',
initOptions: { bits: 512 },
Expand All @@ -89,10 +92,17 @@ function addNode (inProcNode, callback) {
})
}

describe('bitswap', function () {
skipOnWindows('bitswap', function () {
this.timeout(80 * 1000)

let inProcNode // Node spawned inside this process
let fDaemon
let fInProc

before(function () {
fDaemon = IPFSFactory.create({ type: 'js' })
fInProc = IPFSFactory.create({ type: 'proc' })
})

beforeEach(function (done) {
this.timeout(60 * 1000)
Expand Down Expand Up @@ -150,7 +160,7 @@ describe('bitswap', function () {
waterfall([
(cb) => parallel([
(cb) => makeBlock(cb),
(cb) => addNode(inProcNode, cb)
(cb) => addNode(fDaemon, inProcNode, cb)
], cb),
(res, cb) => {
block = res[0]
Expand Down Expand Up @@ -178,11 +188,11 @@ describe('bitswap', function () {
blocks = _blocks
cb()
}),
(cb) => addNode(inProcNode, (err, _ipfs) => {
(cb) => addNode(fDaemon, inProcNode, (err, _ipfs) => {
remoteNodes.push(_ipfs)
cb(err)
}),
(cb) => addNode(inProcNode, (err, _ipfs) => {
(cb) => addNode(fDaemon, inProcNode, (err, _ipfs) => {
remoteNodes.push(_ipfs)
cb(err)
}),
Expand Down Expand Up @@ -213,14 +223,17 @@ describe('bitswap', function () {
})
})

describe('transfer a file between', () => {
describe('transfer a file between', function () {
this.timeout(160 * 1000)

it('2 peers', (done) => {
// TODO make this test more interesting (10Mb file)
// TODO remove randomness from the test
const file = Buffer.from(`I love IPFS <3 ${Math.random()}`)

waterfall([
// 0. Start node
(cb) => addNode(inProcNode, cb),
(cb) => addNode(fDaemon, inProcNode, cb),
// 1. Add file to tmp instance
(remote, cb) => {
remote.files.add([{ path: 'awesome.txt', content: file }], cb)
Expand Down
8 changes: 0 additions & 8 deletions test/fixtures/go-ipfs-repo/blocks/_README
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,17 @@ All the object files are placed in a tree of directories, based on a
function of the CID. This is a form of sharding similar to
the objects directory in git repositories. Previously, we used
prefixes, we now use the next-to-last two charters.

func NextToLast(base32cid string) {
nextToLastLen := 2
offset := len(base32cid) - nextToLastLen - 1
return str[offset : offset+nextToLastLen]
}

For example, an object with a base58 CIDv1 of

zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f

has a base32 CIDv1 of

BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA

and will be placed at

SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data

with 'SC' being the last-to-next two characters and the 'B' at the
beginning of the CIDv1 string is the multibase prefix that is not
stored in the filename.
116 changes: 62 additions & 54 deletions test/fixtures/go-ipfs-repo/config
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
{
"Identity":{
"PeerID":"QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A",
"PrivKey":"CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAECggEAZtju/bcKvKFPz0mkHiaJcpycy9STKphorpCT83srBVQi59CdFU6Mj+aL/xt0kCPMVigJw8P3/YCEJ9J+rS8BsoWE+xWUEsJvtXoT7vzPHaAtM3ci1HZd302Mz1+GgS8Epdx+7F5p80XAFLDUnELzOzKftvWGZmWfSeDnsl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8j//2yiXk0a/T2f36zKMuZvujqQKBgC6B7BAQDG2H2B/ijofp12ejJU36nL98gAZyqOfpLJ+FeMz4TlBDQ+phIMhnHXA5UkdDapQ+zA3SrFk+6yGk9Vw4Hf46B+82SvOrSbmnMa+PYqKYIvUzR4gg34rL/7AhwnbEyD5hXq4dHwMNsIDq+l2elPjwm/U9V0gdAl2+r50HAoGALtsKqMvhv8HucAMBPrLikhXP/8um8mMKFMrzfqZ+otxfHzlhI0L08Bo3jQrb0Z7ByNY6M8epOmbCKADsbWcVre/AAY0ZkuSZK/CaOXNX/AhMKmKJh8qAOPRY02LIJRBCpfS4czEdnfUhYV/TYiFNnKRj57PPYZdTzUsxa/yVTmECgYBr7slQEjb5Onn5mZnGDh+72BxLNdgwBkhO0OCdpdISqk0F0Pxby22DFOKXZEpiyI9XYP1C8wPiJsShGm2yEwBPWXnrrZNWczaVuCbXHrZkWQogBDG3HGXNdU4MAWCyiYlyinIBpPpoAJZSzpGLmWbMWh28+RJS6AQX6KHrK1o2uw=="
},
"Datastore":{
"Type":"",
"Path":"",
"StorageMax":"",
"StorageGCWatermark":0,
"GCPeriod":"",
"Params":null,
"NoSync":false
"Datastore": {
"Type": "",
"Path": "",
"StorageMax": "",
"StorageGCWatermark": 0,
"GCPeriod": "",
"Params": null,
"NoSync": false
},
"Addresses":{
"Swarm":[
"/ip4/127.0.0.1/tcp/9999",
"/ip4/127.0.0.1/tcp/9990/ws"
"Addresses": {
"Swarm": [
"/ip4/127.0.0.1/tcp/0",
"/ip4/127.0.0.1/tcp/0/ws"
],
"API":"/ip4/127.0.0.1/tcp/6001",
"Gateway":"/ip4/127.0.0.1/tcp/0"
"API": "/ip4/127.0.0.1/tcp/0",
"Gateway": "/ip4/127.0.0.1/tcp/0"
},
"Mounts":{
"IPFS":"/ipfs",
"IPNS":"/ipns",
"FuseAllowOther":false
"Mounts": {
"IPFS": "/ipfs",
"IPNS": "/ipns",
"FuseAllowOther": false
},
"Version":{
"Current":"0.4.0-dev",
"Check":"error",
"CheckDate":"0001-01-01T00:00:00Z",
"CheckPeriod":"172800000000000",
"AutoUpdate":"minor"
"Version": {
"Current": "0.4.0-dev",
"Check": "error",
"CheckDate": "0001-01-01T00:00:00Z",
"CheckPeriod": "172800000000000",
"AutoUpdate": "minor"
},
"Discovery":{
"MDNS":{
"Enabled":false,
"Interval":10
"Discovery": {
"MDNS": {
"Enabled": false,
"Interval": 10
},
"webRTCStar": {
"Enabled": false
}
},
"Ipns":{
"RepublishPeriod":"",
"RecordLifetime":"",
"ResolveCacheSize":128
"Ipns": {
"RepublishPeriod": "",
"RecordLifetime": "",
"ResolveCacheSize": 128
},
"Bootstrap":[
"Bootstrap": [
"/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z",
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
Expand All @@ -67,16 +67,16 @@
"/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic",
"/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6"
],
"Tour":{
"Last":""
"Tour": {
"Last": ""
},
"Gateway":{
"HTTPHeaders":null,
"RootRedirect":"",
"Writable":false
"Gateway": {
"HTTPHeaders": null,
"RootRedirect": "",
"Writable": false
},
"SupernodeRouting":{
"Servers":[
"SupernodeRouting": {
"Servers": [
"/ip4/104.236.176.52/tcp/4002/ipfs/QmXdb7tWTxdFEQEFgWBqkuYSrZd3mXrC7HxkD4krGNYx2U",
"/ip4/104.236.179.241/tcp/4002/ipfs/QmVRqViDByUxjUMoPnjurjKvZhaEMFDtK35FJXHAM4Lkj6",
"/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH",
Expand All @@ -87,15 +87,23 @@
"/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN"
]
},
"API":{
"HTTPHeaders":null
"API": {
"HTTPHeaders": null
},
"Swarm":{
"AddrFilters":null
"Swarm": {
"AddrFilters": null
},
"Log":{
"MaxSizeMB":250,
"MaxBackups":1,
"MaxAgeDays":0
"Log": {
"MaxSizeMB": 250,
"MaxBackups": 1,
"MaxAgeDays": 0
},
"Keychain": {
"dek": {
"keyLength": 64,
"iterationCount": 10000,
"salt": "co5EbMmrhFwmhHjedZU73zhL",
"hash": "sha2-512"
}
}
}
}
2 changes: 1 addition & 1 deletion test/fixtures/go-ipfs-repo/datastore/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000014
MANIFEST-000017
30 changes: 1 addition & 29 deletions test/fixtures/go-ipfs-repo/datastore/LOG
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
=============== Aug 25, 2016 (CEST) ===============
17:21:42.391799 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
17:21:42.393115 db@open opening
17:21:42.399749 db@janitor F·5 G·1
17:21:42.399774 db@janitor removing manifest-4
17:21:42.399904 db@open done T·6.754896ms
=============== Aug 25, 2016 (CEST) ===============
17:36:56.009638 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
17:36:56.009849 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50]
17:36:56.009874 db@open opening
17:36:56.009943 journal@recovery F·1
17:36:56.010918 journal@recovery recovering @8
17:36:56.012317 memdb@flush created L0@10 N·4 S·1KiB "/ip..\xf6\xe4\xa9,d12":"/pk..TOA,v9"
17:36:56.013451 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75]
17:36:56.014779 db@janitor F·5 G·0
17:36:56.014815 db@open done T·4.928147ms
17:36:56.030081 db@close closing
17:36:56.030223 db@close done T·138.943µs
=============== Aug 25, 2016 (CEST) ===============
17:37:32.735975 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
17:37:32.736209 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75]
17:37:32.736230 db@open opening
17:37:32.736304 journal@recovery F·1
17:37:32.737385 journal@recovery recovering @11
17:37:32.738575 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75]
17:37:32.739466 db@janitor F·5 G·0
17:37:32.739492 db@open done T·3.248709ms
17:37:51.684973 db@close closing
17:37:51.685242 db@close done T·168.908µs
2018/02/27-08:48:29.247686 7000091b5000 Delete type=3 #15
Loading

0 comments on commit bc66e9f

Please sign in to comment.