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

Diorama-based app spec tests #1475

Merged
merged 32 commits into from Jun 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e5b5010
Merge branch 'reset-conductor-api-after-adding-bridge' into diorama-a…
maackle Jun 3, 2019
d12d95a
Update app spec tests for diorama
maackle Jun 3, 2019
afa6430
fmt
maackle Jun 3, 2019
c1cb5ba
Merge remote-tracking branch 'origin/develop' into diorama-app-spec-t…
maackle Jun 3, 2019
f97e0e5
Build rust conductor instead of node conductor
maackle Jun 3, 2019
a9a2a5a
Debugging git hash discrepancy
maackle Jun 3, 2019
00a17dc
Experiment with sleep to remove flakiness
maackle Jun 4, 2019
954ca74
tweaks for flaky app spec tests
thedavidmeister Jun 4, 2019
e166c40
fmt
thedavidmeister Jun 4, 2019
49a7fa8
fix app spec regression tests
thedavidmeister Jun 4, 2019
db2ba57
remove vb.gui from vagrant
thedavidmeister Jun 4, 2019
a5ee9ab
dont commit vagrant
thedavidmeister Jun 4, 2019
e9f0657
Merge remote-tracking branch 'origin/develop' into diorama-app-spec-t…
maackle Jun 4, 2019
c3b776a
set text=auto
thedavidmeister Jun 5, 2019
3870ecd
Merge remote-tracking branch 'origin/develop' into diorama-app-spec-t…
maackle Jun 6, 2019
30963d4
Merge branch 'diorama-app-spec-tests' of github.com:holochain/holocha…
maackle Jun 6, 2019
fcacacb
Use different diorama storage dir
maackle Jun 6, 2019
777c903
Bump diorama, longer timeout
maackle Jun 6, 2019
3946412
Bump diorama ver
maackle Jun 6, 2019
3b44e47
Bump diorama
maackle Jun 6, 2019
e486755
Revert "Bump diorama"
maackle Jun 6, 2019
6dee369
add a ton of swap to vagrant to shoehorn app spec tests in
thedavidmeister Jun 6, 2019
758285e
wip on git attributes for lf
thedavidmeister Jun 6, 2019
6c7092e
dos2unix for holonix
thedavidmeister Jun 6, 2019
57fc10c
dos2unix sweep
thedavidmeister Jun 6, 2019
d9bef2f
Merge branch 'diorama-app-spec-tests' of https://github.com/holochain…
thedavidmeister Jun 6, 2019
8218fe0
Merge branch 'diorama-app-spec-tests' of github.com:holochain/holocha…
maackle Jun 6, 2019
7a88d01
bump diorama
maackle Jun 7, 2019
4ee7f15
merged develop into diorama-app-spec-tests
zippy Jun 7, 2019
cae68b9
Bump diorama
maackle Jun 8, 2019
6e579d2
bump diorama
maackle Jun 8, 2019
54066f2
Merge branch 'develop' into diorama-app-spec-tests
lucksus Jun 8, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitattributes
@@ -0,0 +1,6 @@
* text=auto
* text eol=lf
* text eol=lf

[core]
autocrlf=input
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -36,6 +36,7 @@ tmp-test-conductor-config.toml
tmp-*-conductor-config.toml

app_spec_proc_macro/test/*
**/diorama-storage

Cargo.lock
dist/**
1 change: 0 additions & 1 deletion .vagrant/machines/default/virtualbox/action_provision

This file was deleted.

1 change: 0 additions & 1 deletion .vagrant/machines/default/virtualbox/action_set_name

This file was deleted.

1 change: 0 additions & 1 deletion .vagrant/machines/default/virtualbox/box_meta

This file was deleted.

1 change: 0 additions & 1 deletion .vagrant/machines/default/virtualbox/creator_uid

This file was deleted.

1 change: 0 additions & 1 deletion .vagrant/machines/default/virtualbox/id

This file was deleted.

1 change: 0 additions & 1 deletion .vagrant/machines/default/virtualbox/index_uuid

This file was deleted.

27 changes: 0 additions & 27 deletions .vagrant/machines/default/virtualbox/private_key

This file was deleted.

1 change: 0 additions & 1 deletion .vagrant/machines/default/virtualbox/synced_folders

This file was deleted.

1 change: 0 additions & 1 deletion .vagrant/machines/default/virtualbox/vagrant_cwd

This file was deleted.

9 changes: 0 additions & 9 deletions .vagrant/rgloader/loader.rb

This file was deleted.

31 changes: 17 additions & 14 deletions Vagrantfile
Expand Up @@ -12,6 +12,8 @@ Vagrant.configure("2") do |config|

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
# config.vm.box = "holochain-vagrant"
# config.vm.box_url = "https://holochain-vagrant-builds.s3-us-west-2.amazonaws.com/holochain-vagrant.zip"
config.vm.box = "nixos/nixos-18.03-x86_64"

# Disable automatic box update checking. If you disable this, then
Expand Down Expand Up @@ -54,7 +56,7 @@ Vagrant.configure("2") do |config|
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
vb.gui = true
vb.gui = false
#
# Customize the amount of memory on the VM:
vb.memory = "10000"
Expand All @@ -65,20 +67,21 @@ Vagrant.configure("2") do |config|
# View the documentation for the provider you are using for more
# information on available options.

# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
# vagrant plugin install vagrant-nixos-plugin
# config.vm.provision :shell, inline: "fallocate -l 4G /swapfile && chmod 0600 /swapfile && mkswap /swapfile && swapon /swapfile"

# add some simple dev tools
config.vm.provision :nixos,
run: 'always',
expression: {
swapDevices: [ { device: "/swapfile", size: 10000 } ],
environment: {
systemPackages: [ :htop, :dos2unix, :vim ]
}
}


# https://askubuntu.com/questions/317338/how-can-i-increase-disk-size-on-a-vagrant-vm
config.disksize.size = '50GB'
# config.disksize.size = '50GB'

config.vm.provision "shell", inline: <<-SHELL
# curl https://nixos.org/nix/install | sh
# . /home/vagrant/.nix-profile/etc/profile.d/nix.sh
# ( cd /vagrant && nix-shell --run hc-test )
SHELL
end
7 changes: 5 additions & 2 deletions app_spec/build_and_test.sh
@@ -1,8 +1,11 @@
#! /bin/bash
#!/usr/bin/env bash
mkdir -p dist
echo "===================================================================================="
echo "RUNNING cargo test for zomes"
echo "Using conductor binary: `which holochain`"
echo "Using cli binary: `which hc`"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the sources of whichiness @thedavidmeister

echo "------------------------------------------------------------------------------------"

cargo test --manifest-path zomes/blog/code/Cargo.toml
cargo test --manifest-path zomes/summer/code/Cargo.toml
echo "===================================================================================="
Expand All @@ -17,4 +20,4 @@ echo "Running test.js in node"
echo "------------------------------------------------------------------------------------"
cd test
npm install
npm test
npm run test-ci
31 changes: 31 additions & 0 deletions app_spec/test/index.js
@@ -0,0 +1,31 @@
const path = require('path')
const tape = require('tape')

const { Diorama, tapeExecutor, backwardCompatibilityMiddleware } = require('@holochain/diorama')

process.on('unhandledRejection', error => {
// Will print "unhandledRejection err is not defined"
console.error('got unhandledRejection:', error);
});

const dnaPath = path.join(__dirname, "../dist/app_spec.dna.json")
const dna = Diorama.dna(dnaPath, 'app-spec')

const diorama = new Diorama({
instances: {
alice: dna,
bob: dna,
carol: dna,
},
bridges: [
Diorama.bridge('test-bridge', 'alice', 'bob')
],
debugLog: false,
executor: tapeExecutor(require('tape')),
middleware: backwardCompatibilityMiddleware,
})

require('./regressions')(diorama.registerScenario)
require('./test')(diorama.registerScenario)

diorama.run()
4 changes: 3 additions & 1 deletion app_spec/test/package.json
@@ -1,12 +1,14 @@
{
"devDependencies": {},
"dependencies": {
"@holochain/diorama": "^0.1.1",
"faucet": "0.0.1",
"json3": "*",
"sleep": "^5.2.3",
"tape": "^4.9.1"
},
"scripts": {
"test": "./run.sh"
"test": "./run.sh",
"test-ci": "./run-ci.sh"
}
}
66 changes: 28 additions & 38 deletions app_spec/test/regressions.js
@@ -1,68 +1,56 @@
const path = require('path')
const { Config, Conductor, Scenario } = require('../../nodejs_conductor')
Scenario.setTape(require('tape'))
module.exports = scenario => {

const dnaPath = path.join(__dirname, "../dist/app_spec.dna.json")
const dna = Config.dna(dnaPath, 'app-spec')
const agentAlice = Config.agent("alice")
const agentTash = Config.agent("tash")
scenario('calling get_links before link_entries makes no difference', async (s, t, {alice}) => {

const instanceAlice = Config.instance(agentAlice, dna)
const instanceTash = Config.instance(agentTash, dna)

const scenario = new Scenario([instanceAlice, instanceTash], { debugLog: true })

scenario.runTape('calling get_links before link_entries makes no difference', async (t, {alice}) => {

const get1 = alice.call("blog", "my_posts", {})
const get1 = await alice.call("blog", "my_posts", {})
t.ok(get1.Ok)

const create1 = await alice.callSync("blog","create_post", {content: 'hi'})
t.ok(create1.Ok)

const get2 = alice.call("blog", "my_posts", {})
const get2 = await alice.call("blog", "my_posts", {})
t.ok(get2.Ok)

t.equal(get2.Ok.links.length, 1)
})

scenario.runTape('calling get_links twice in a row is no different than calling it once', async (t, {alice}) => {
scenario('calling get_links twice in a row is no different than calling it once', async (s, t, {alice}) => {
// This test is exactly the same as the previous one, but calls my_posts twice in a row.
// This makes the links come through the second time.

const get1 = alice.call("blog", "my_posts", {})
const get1 = await alice.call("blog", "my_posts", {})
t.ok(get1.Ok)

const create1 = await alice.callSync("blog", "create_post", {content: 'hi'})
t.ok(create1.Ok)

alice.call("blog", "my_posts", {})
const get2 = alice.call("blog", "my_posts", {})
await alice.call("blog", "my_posts", {})
const get2 = await alice.call("blog", "my_posts", {})
t.ok(get2.Ok)

t.equal(get2.Ok.links.length, 1)
})

scenario.runTape('not calling get_links in the beginning is also ok', async (t, {alice}) => {
scenario('not calling get_links in the beginning is also ok', async (s, t, {alice}) => {

const create1 = await alice.callSync("blog", "create_post", {content: 'hi'})
t.ok(create1.Ok)

const get1 = alice.call("blog", "my_posts", {})
const get1 = await alice.call("blog", "my_posts", {})
t.ok(get1.Ok)

t.equal(get1.Ok.links.length, 1)
})

scenario.runTape('alice create & publish post -> recommend own post to self', async (t, {alice, tash}) => {
scenario('alice create & publish post -> recommend own post to self', async (s, t, {alice, bob}) => {

const content = "Holo world...1"
const params = { content: content, in_reply_to: null }
const postResult = await alice.callSync("blog", "create_post", params)
const postAddr = postResult.Ok
t.ok(postAddr, `error: ${postResult}`)

const gotPost = alice.call("blog", "get_post", {post_address: postAddr})
const gotPost = await alice.call("blog", "get_post", {post_address: postAddr})
t.ok(gotPost.Ok)

let linked = await alice.callSync('blog', 'recommend_post', {
Expand All @@ -72,57 +60,59 @@ scenario.runTape('alice create & publish post -> recommend own post to self', as
console.log("linked: ", linked)
t.equal(linked.Ok, "QmZr5F34uGZjAEwmU574VwiRtXGHQmvbUnNgA2MJz7YcTr")

const recommendedPosts = alice.call('blog', 'my_recommended_posts', {})
const recommendedPosts = await alice.call('blog', 'my_recommended_posts', {})
console.log("recommendedPosts", recommendedPosts)
console.log('agent addresses: ', alice.agentId, alice.agentId)

t.equal(recommendedPosts.Ok.links.length, 1)
})

scenario.runTape('alice create & publish post -> tash recommend to self', async (t, {alice, tash}) => {
scenario('alice create & publish post -> bob recommend to self', async (s, t, {alice, bob}) => {
const content = "Holo world...2"
const params = { content: content, in_reply_to: null }
const postResult = await alice.callSync("blog", "create_post", params)
const postAddr = postResult.Ok
t.ok(postAddr, `error: ${postResult}`)

const gotPost = tash.call("blog", "get_post", {post_address: postAddr})
const gotPost = await bob.call("blog", "get_post", {post_address: postAddr})
t.ok(gotPost.Ok)

let linked = await tash.callSync('blog', 'recommend_post', {
let linked = await bob.callSync('blog', 'recommend_post', {
post_address: postAddr,
agent_address: tash.agentId
agent_address: bob.agentId
})
console.log("linked: ", linked)
t.equal(linked.Ok, "QmT2Z8Hdkgxkt7X4ZeEkoDt3YTQBzyJa1RNPhfkj9icsQ4")
t.equal(linked.Ok, "QmaLKGRgSHv6z73FaseCgudGt9uZ9fPhBREUy3gZ1C8s2K")

const recommendedPosts = tash.call("blog", "my_recommended_posts", {})
const recommendedPosts = await bob.call("blog", "my_recommended_posts", {})
console.log("recommendedPosts", recommendedPosts)
console.log('agent addresses: ', alice.agentId, tash.agentId)
console.log('agent addresses: ', alice.agentId, bob.agentId)

t.equal(recommendedPosts.Ok.links.length, 1)
})

scenario.runTape('create & publish post -> recommend to other agent', async (t, {alice, tash}) => {
scenario('create & publish post -> recommend to other agent', async (s, t, {alice, bob}) => {
const content = "Holo world...3"
const params = { content: content, in_reply_to: null }
const postResult = await alice.callSync("blog", "create_post", params)
const postAddr = postResult.Ok
t.ok(postAddr, `error: ${postResult}`)

const gotPost = tash.call("blog", "get_post", {post_address: postAddr})
const gotPost = await bob.call("blog", "get_post", {post_address: postAddr})
t.ok(gotPost.Ok)

let linked = await alice.callSync('blog', 'recommend_post', {
post_address: postAddr,
agent_address: tash.agentId
agent_address: bob.agentId
})
console.log("linked: ", linked)
t.equal(linked.Ok, "QmUFkn3kTXuFmBvynEMQ4ox3WyvkkG4GtfvPkNqb5b7Ge7")
t.equal(linked.Ok, "QmWBQCMdgZURpxa7WsbxnnVNZcFxdaTV7mxVdgh9nHnVwT")

const recommendedPosts = tash.call('blog', 'my_recommended_posts', {})
const recommendedPosts = await bob.call('blog', 'my_recommended_posts', {})
console.log("recommendedPosts", recommendedPosts)
console.log('agent addresses: ', alice.agentId, tash.agentId)
console.log('agent addresses: ', alice.agentId, bob.agentId)

t.equal(recommendedPosts.Ok.links.length, 1)
})

}
11 changes: 11 additions & 0 deletions app_spec/test/run-ci.sh
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

mkdir -p diorama-storage

STORAGE="`pwd`/diorama-storage"
rm -fr $STORAGE
mkdir $STORAGE
if [ -z $1];
then DIORAMA_STORAGE=$STORAGE node index.js | tee test.out~ | faucet || ( cat test.out~; false );
else DIORAMA_STORAGE=$STORAGE node $1;
fi;
7 changes: 4 additions & 3 deletions app_spec/test/run.sh
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
if [ -z $1];
then tape test.js regressions.js | tee test.out~ | faucet || ( cat test.out~; false );
else tape $1;
fi;
then node index.js | tee test.out~ | faucet || ( cat test.out~; false );
else node $1;
fi;